Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/parro-it/electron-detach
Restart an electron app as a detached process
https://github.com/parro-it/electron-detach
Last synced: 2 months ago
JSON representation
Restart an electron app as a detached process
- Host: GitHub
- URL: https://github.com/parro-it/electron-detach
- Owner: parro-it
- License: mit
- Created: 2015-10-28T19:25:12.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-12-15T13:13:07.000Z (about 6 years ago)
- Last Synced: 2024-05-23T03:21:13.975Z (8 months ago)
- Language: JavaScript
- Homepage:
- Size: 13.7 KB
- Stars: 59
- Watchers: 3
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
- awesome-electron - electron-detach - Restart an Electron app as a detached process. ![](https://img.shields.io/github/stars/parro-it/electron-detach.svg?style=social&label=Star) (Library / Uncategorized)
- awesome-electron-zh - electron-detach - Restart an Electron app as a detached process. (Tools / For Electron)
README
# electron-detach
This module restart the app as a detached electron process,
allowing an electron app to be started from terminal and
survive parent process closure.[![Travis Build Status](https://img.shields.io/travis/parro-it/electron-detach.svg)](http://travis-ci.org/parro-it/electron-detach)
[![NPM module](https://img.shields.io/npm/v/electron-detach.svg)](https://npmjs.org/package/electron-detach)
[![NPM downloads](https://img.shields.io/npm/dt/electron-detach.svg)](https://npmjs.org/package/electron-detach)## Installation
```bash
npm install --save electron-detach
```## Usage
```javascript
const electronDetach = require('electron-detach');//returns true if your process is a detached child process
if (electronDetach({ requireCmdlineArg: false })) {
app.on('ready',()=>{
//turn the app on
});
}
```## Api
Calling `electronDetach()` returns `true` if current process is already detached from the terminal.
If calling `electronDetach()` returns `false` the process will be killed as soon a detached one is spawned.If calling `electronDetach()` returns `true`, this means that it is good to start your app now. If it returns `false`, your process will shortly be terminated.
```javascript
const electronDetach = require('electron-detach');
if(electronDetach()){
//Turn your app on, as your app is in a process that is not going to be killed
} else {
//Your app is going to be killed. Respond accordingly
}
```### Option argument
An optional object containing following property:
* requireCmdlineArg
only restart the app if --detach command line argument is present.
Defaults to false.* outputPath
Path to a file where stdout and stderr of detached process will be redirected. Defaults to /dev/null
## License
The MIT License (MIT)
Copyright (c) 2015 Andrea Parodi