Skip to content

Instantly share code, notes, and snippets.

@maxp
Created July 5, 2013 11:45
Show Gist options
  • Select an option

  • Save maxp/5934008 to your computer and use it in GitHub Desktop.

Select an option

Save maxp/5934008 to your computer and use it in GitHub Desktop.
nodejs exit on source file timestamp change
fs = require 'fs'
_reload_timestamp = null
setInterval(
-> fs.stat __filename, (err, stat) ->
_reload_timestamp ?= stat.mtime
if stat.mtime > _reload_timestamp
console.info "reloading"
process.exit(100)
3000
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment