gur6fg
Last Updated: February 25, 2016
·
421
· geta6
570703a3265d666c5fdb55f007b9b620

daemonize nodejs

daemonize your application :P

unless process.env.__daemon
  args = [].concat process.argv
  args.shift()
  args.shift()
  process.env.__daemon = yes
  child = spawn process.mainModule.filename, args,
    stdio: 'ignore'
    env: process.env
    cwd: process.cwd()
    detached: yes
  child.unref()
  process.exit 0
fs.writeFileSync 'app.pid', process.pid
Say Thanks
Respond