How to use the node-graceful.timeout function in node-graceful

To help you get started, we’ve selected a few node-graceful examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fgnass / instant / lib / index.js View on Github external
}

    if (root && opts.watch !== false) {
      var urlsByFile = {}

      fn.watcher = filewatcher({ delay: opts.delay })

      // Stop the file system watcher so apps can exit gracefully when
      // terminated by Ctrl+c (SIGINT) or a polite termination request (SIGTERM).
      // You can also call the cleanUp() function directly to handle housekeeping
      // in your own server (e.g., when it is asked to close).
      fn.cleanUp = function (done) {
        fn.watcher.removeAll()
        done()
      }
      Graceful.timeout = 3000
      Graceful.on('SIGINT', fn.cleanUp)
      Graceful.on('SIGTERM', fn.cleanUp)

      // when a file is modifed tell all clients to reload it
      fn.watcher.on('change', function(file) {
        fn.reload(urlsByFile[file])
      })

      // build a RegExp to match all watched file extensions
      var exts = opts.watch || ['html', 'js', 'css']
        , re = new RegExp('\\.(' + exts.join('|') + ')$')

      // pass an `onfile` handler that watches matching files
      opts = Object.create(opts, {
        onfile: { value: function(path, stat) {
          if (!re.test(path)) return

node-graceful

Graceful process exit manager. allows waiting on multiple async services.

MIT
Latest version published 3 years ago

Package Health Score

45 / 100
Full package analysis

Popular node-graceful functions