mirror of
https://github.com/SrIzan10/nodemon.git
synced 2026-05-01 10:55:09 +00:00
feat: support SIGHUP to restart nodemon
Also small linting tweaks and typos in comments. Fixes #393
This commit is contained in:
19
Dockerfile
19
Dockerfile
@@ -1,19 +0,0 @@
|
||||
FROM ubuntu:12.04
|
||||
MAINTAINER Remy Sharp <remy@leftlogic.com>
|
||||
|
||||
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
|
||||
RUN apt-get update && apt-get install curl npm -y
|
||||
|
||||
ENV NVM_DIR /usr/local/nvm
|
||||
ENV NODE_VERSION 4
|
||||
ENV NVM_VERSION 0.26.1
|
||||
ENV TRAVIS TRUE
|
||||
|
||||
# # Install nvm with node and npm
|
||||
RUN curl https://raw.githubusercontent.com/creationix/nvm/v$NVM_VERSION/install.sh | bash \
|
||||
&& source $NVM_DIR/nvm.sh \
|
||||
&& nvm install 0.10 \
|
||||
&& nvm install 0.12 \
|
||||
&& nvm install 4 \
|
||||
&& nvm alias default $NODE_VERSION \
|
||||
&& nvm use default
|
||||
@@ -16,6 +16,7 @@ module.exports = {
|
||||
stdin: true,
|
||||
runOnChangeOnly: false,
|
||||
verbose: false,
|
||||
signal: 'SIGUSR2',
|
||||
// 'stdout' refers to the default behaviour of a required nodemon's child,
|
||||
// but also includes stderr. If this is false, data is still dispatched via
|
||||
// nodemon.on('stdout/stderr')
|
||||
|
||||
@@ -31,7 +31,6 @@ var config = {
|
||||
dirs: [],
|
||||
timeout: 1000,
|
||||
options: {},
|
||||
signal: 'SIGUSR2',
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -59,7 +58,7 @@ config.load = function (settings, ready) {
|
||||
}
|
||||
|
||||
config.watchInterval = options.watchInterval || null;
|
||||
if (options['signal']) { // jshint ignore:line
|
||||
if (options.signal) {
|
||||
config.signal = options.signal;
|
||||
}
|
||||
|
||||
|
||||
@@ -135,21 +135,23 @@ function nodemon(settings) {
|
||||
config.options.restartable + '`');
|
||||
}
|
||||
|
||||
var none = function (v) {
|
||||
return v;
|
||||
};
|
||||
if (!config.required) {
|
||||
const restartSignal = config.options.signal === 'SIGUSR2' ? 'SIGHUP' : 'SIGUSR2';
|
||||
process.on(restartSignal, nodemon.restart);
|
||||
utils.log.detail((config.options.restartable ? 'or ' : '') + 'send ' +
|
||||
restartSignal + ' to ' + process.pid + ' to restart');
|
||||
}
|
||||
|
||||
utils.log.detail('ignoring: ' + config.options.monitor.map(function (rule) {
|
||||
return rule.slice(0, 1) === '!' ? rule.slice(1) : false;
|
||||
}).filter(none).join(' '));
|
||||
}).filter(Boolean).join(' '));
|
||||
|
||||
utils.log.info('watching: ' + config.options.monitor.map(function (rule) {
|
||||
return rule.slice(0, 1) !== '!' ? rule : false;
|
||||
}).filter(none).join(' '));
|
||||
}).filter(Boolean).join(' '));
|
||||
|
||||
utils.log.detail('watching extensions: ' + config.options.execOptions.ext);
|
||||
|
||||
|
||||
if (config.options.dump) {
|
||||
utils.log._log('log', '--------------');
|
||||
utils.log._log('log', 'node: ' + process.version);
|
||||
@@ -164,33 +166,35 @@ function nodemon(settings) {
|
||||
process.exit();
|
||||
}
|
||||
|
||||
} else {
|
||||
config.run = true;
|
||||
|
||||
if (config.options.stdout === false) {
|
||||
nodemon.on('start', function () {
|
||||
nodemon.stdout = bus.stdout;
|
||||
nodemon.stderr = bus.stderr;
|
||||
|
||||
bus.emit('readable');
|
||||
});
|
||||
}
|
||||
|
||||
if (config.options.events && Object.keys(config.options.events).length) {
|
||||
Object.keys(config.options.events).forEach(function (key) {
|
||||
utils.log.detail('bind ' + key + ' -> `' +
|
||||
config.options.events[key] + '`');
|
||||
nodemon.on(key, function () {
|
||||
if (config.options && config.options.events) {
|
||||
spawn(config.options.events[key], config,
|
||||
[].slice.apply(arguments));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
monitor.run(config.options);
|
||||
return;
|
||||
}
|
||||
|
||||
config.run = true;
|
||||
|
||||
if (config.options.stdout === false) {
|
||||
nodemon.on('start', function () {
|
||||
nodemon.stdout = bus.stdout;
|
||||
nodemon.stderr = bus.stderr;
|
||||
|
||||
bus.emit('readable');
|
||||
});
|
||||
}
|
||||
|
||||
if (config.options.events && Object.keys(config.options.events).length) {
|
||||
Object.keys(config.options.events).forEach(function (key) {
|
||||
utils.log.detail('bind ' + key + ' -> `' +
|
||||
config.options.events[key] + '`');
|
||||
nodemon.on(key, function () {
|
||||
if (config.options && config.options.events) {
|
||||
spawn(config.options.events[key], config,
|
||||
[].slice.apply(arguments));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
monitor.run(config.options);
|
||||
|
||||
});
|
||||
|
||||
return nodemon;
|
||||
|
||||
@@ -13,7 +13,7 @@ var reAsterisk = /\*/g;
|
||||
module.exports = add;
|
||||
|
||||
/**
|
||||
* Coverts file patterns or regular expressions to nodemon
|
||||
* Converts file patterns or regular expressions to nodemon
|
||||
* compatible RegExp matching rules. Note: the `rules` argument
|
||||
* object is modified to include the new rule and new RegExp
|
||||
*
|
||||
@@ -86,4 +86,4 @@ function add(rules, which, rule) {
|
||||
// used for the directory matching
|
||||
rules[which].re = new RegExp(re);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user