demonize v2.0.0
Demonize
Demonize / Daemonize With Node.js
This library will demonize a program and return the child process. It can also create a standalone demonizable script that can be started just like a bash script ./demon.js
Examples
const Demonize = require('demonize');
const options = {
arg: 'server.js',
env: { PORT: 8000 },
err: __dirname + '/out.log',
out: __dirname + '/out.log'
};
const child = await Demonize.it(options);
console.log(child);const Demonize = require('demonize');
const options = {
env: { PORT: 8000 },
arg: ['server.js'],
err: __dirname + '/out.log',
out: __dirname + '/out.log',
fd: '/Path/To/Add/Generated/demon.js'
};
await Demonize.generate(options);
console.log('Created standalone demonize script');API
Demonize.it-options: ObjectrequiredDemonize.generate-options: Objectrequired
Options
The same options that are available to the Node.js ChildProcess.spawn are also available as options.
arg: String || ArrayA string or array of arguments. Alias forargs.env: Object(Defaults{})cmd: StringThe path to the executable (Defaultprocess.execPath)cwd: StringThe path to the current working directory (Defaultprocess.cwd())out: StringThe path to a file/path/out.logorignore(Defaults toignore)err: StringThe path to a file/path/err.logorignore(Defaults toignore)fd: StringThe path to output a generated demon file (Default./demon.js)
Authors
License
Why You Should Choose MPL-2.0 This project is licensed under the MPL-2.0 License