Skip to content

Instantly share code, notes, and snippets.

@unixpickle
Created December 31, 2013 20:46
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 unixpickle/8202073 to your computer and use it in GitHub Desktop.
Save unixpickle/8202073 to your computer and use it in GitHub Desktop.
A nodule for running and stopping an HTTP service
if process.argv.length != 4
console.log 'Usage: coffee main.coffee <start cmd> <stop cmd>'
process.exit 1
{exec} = require 'child_process'
stopApache = ->
exec process.argv[3], ->
process.exit()
process.on 'SIGINT', stopApache
process.on 'SIGTERM', stopApache
exec process.argv[2]
loopFn = ->
setTimeout loopFn, 100000
loopFn()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment