simplywatch
Version:
Watches files and upon change executes a command for each file INDIVIDUALLY with file-related params
20 lines (12 loc) • 528 B
text/coffeescript
module.exports = (args)-> if args.background
if process.env.__daemon
console.log "Running as daemon - PID #{process.pid}"
notifyDeath = ()-> console.log 'KILLED - exiting'; process.exit()
process.on 'SIGTERM', notifyDeath
process.on 'SIGINT', notifyDeath
else
fs.open args.log, 'w', (err, outputFile)->
throw err if err
daemon = require('daemon-plus')({stdout:outputFile, stderr:outputFile}, true)
console.log chalk.bgGreen.black.bold('Running as daemon'), "PID #{daemon.pid}"
process.exit()