All Projects → parro-it → electron-detach

parro-it / electron-detach

Licence: MIT License
Restart an electron app as a detached process

Programming Languages

javascript
184084 projects - #8 most used programming language

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 NPM module NPM downloads

Installation

npm install --save electron-detach

Usage

  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.

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].