Skip to content

Instantly share code, notes, and snippets.

@homam
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save homam/ef126ed849d0357a7c3f to your computer and use it in GitHub Desktop.
Save homam/ef126ed849d0357a7c3f to your computer and use it in GitHub Desktop.
Keeping child process open in node. Instead of Ctrl+c use `process.exit 0`

Start:

chmod +x ./start.sh 
./start.sh

Remember to kill the ./start.sh:

ps -ax | grep "start.sh" | grep -v "grep" # find the PID of start.sh
kill -9 4393
fs = require \fs
_ <- fs.append-file './log.txt', "Child Started #{new Date!}\n"
<- setTimeout _ , 12000
fs.append-file './log.txt', "Child Ended #{new Date!}\n\n"
fork = require("child_process").fork
child = fork(__dirname + "/child-process.js");
process.exit 0
#!/bin/bash
lsc -c *.ls && node parent-process.js
(
while true
do
ps -a | grep "node" | grep -v "grep"
sleep 5
done
) &
disown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment