springbokjs-daemon

2019-07-10 admin

springbokjs-daemon是什么

什么是springbokjs-daemon,Springbok Daemon, usable with Gulp and Grunt to restart your server on watch

springbokjs-daemon使用教程帮助文档

springbokjs-daemon

Springbok Daemon, usable with Gulp and Grunt to restart your server on watch

Install

npm install --save-dev springbokjs-daemon

API

All arguments are optional, but you should at least provide command or args.

import createDaemon from 'springbokjs-daemon';

const daemon = createDaemon({
  key: '', // logger key
  displayName: '', // logger displayName
  command: 'node', // default to process.argv[0]
  args: [],
  autorestart: false, // autorestart when the child kills itself
  SIGTERMTimeout: 4000, // time to wait before sending SIGKILL
});

daemon.start(); // returns a Promise on the event ready
daemon.restart(); // do stop() then start()
daemon.stop(); // send SIGTERM then SIGKILL and returns a Promise when the child is killed.

Message

You can send these messages using process.send:

  • ready: to notify that the instance has successfully started
  • restart: ask for a clean restart of the process

Use case with Gulp

var gulp = require('gulp');
var createDaemon = require('springbokjs-daemon');

var daemon = createDaemon({ args: ['src/server/server.js'] });
process.on('exit', function(code) {
    daemon.stop();
});

gulp.task('watch', ['default'], function() {
    daemon.start();
    gulp.watch('src/server/**/*.js').on('change', function() {
        daemon.restart();
    });
});

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-69352.html

文章标题:springbokjs-daemon

回到顶部