exec('nohup node some.js &')
See original GitHub issueNot sure if its a bug rather question.
- node - 5.10.0
- shelljs - ^0.6.0
- os - OS X 10.11.4
Can I do something like:
// index.js
require('shelljs/global');
const path = require('path');
const target = path.join(process.cwd(), process.argv[2])
exec('nohup node ./watcher.js ' + target + '&');
// watcher.js
const fs = require('fs');
function watch(dir) {
fs.watch(dir, (event, filename) => {
if (filename) {
// do something
}
});
}
watch(process.argv[2]);
node src/index.js ./test/fixtures
I expect the index.js
to terminate and on ps -ef | grep watcher
to find the process
corresponding to watcher.js
listed
In practice it doesn’t. Is it by design?
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
How to run Node.js as a background process and never die?
nohup means: Do not terminate this process even when the stty is cut off. > /dev/null means: stdout goes to /dev/null (which is...
Read more >Starting a Node.js process using UNIX's boilerplate tools
If I try to open a new terminal, it automatically runs two processes, the first is iTerm's internal process, and the second one...
Read more >Runing Node JS Server In Background - Iulian Popa
The nohup command will run commands in background, in this case, it will start our Node JS HTTP web server in background and...
Read more >How to run a node.js app as a background service
The nohup is another Command Line Interface Tool which can be used to run a node.js app as a background service. Run the...
Read more >How to use nohup to continue to run a command after the user ...
But, I would like to continue to run the program after I logout from SSH. When I run nohup <installation_dir>/nodejs/bin/node <js_program.js> > ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@kevin-smets thanks for following up on this issue.
However, this is not a ShellJS bug.
child_process.execSync()
andchild_process.exec()
both have the same issue, so there’s nothing we can do here (our.exec()
is built upon those).For this specific example, here’s some thoughts:
nohup
and&
)node
is installed under a different name (e.g.nodejs
on Ubuntu)&
on the end?.fork()
above) should be sufficient.kill()
. Otherwise, you’ve got processes running around on their own on your system (yikes!)Another option is:
Or
stdio:'inherit'
, for terminal io.