Skip to content

Commit

Permalink
Support manual restart using "rs" command. Fixes #162
Browse files Browse the repository at this point in the history
  • Loading branch information
remy committed Apr 30, 2013
1 parent 6b41992 commit 8ca0264
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
12 changes: 8 additions & 4 deletions README.md
Expand Up @@ -11,7 +11,7 @@ nodemon does **not** require *any* changes to your code or method of development
Either through forking or by using [npm](http://npmjs.org) (the recommended way):

npm install -g nodemon

And nodemon will be installed in to your bin path. Note that as of npm v1, you must explicitly tell npm to install globally as nodemon is a command line utility.

# Usage
Expand Down Expand Up @@ -42,6 +42,10 @@ If you have a `package.json` file for your app, you can omit the main script ent

nodemon was original written to restart hanging processes such as web servers, but now supports apps that cleanly exit. If your script exits cleanly, nodemon will continue to monitor the directory (or directories) and restart the script if there are any changes.

# Manual restarting

Whilst nodemon is running, if you need to manually restart your application, instead of stopping and restart nodemon, you can simply type `rs` with a carridge return, and nodemon will restart your process.

# Running non-node scripts

nodemon can also be used to execute and monitor other programs. nodemon will read the file extension of the script being run and monitor that extension instead of .js if there's no .nodemonignore:
Expand All @@ -62,11 +66,11 @@ Now nodemon will only restart if there are changes in the `./app` or `./libs` di

By default, nodemon looks for files with the `.js` extension. If you use the `--exec` option and monitor `app.py` nodemon will monitor files with the extension of `.py`. However, you can specify your own list with the `-e` switch like so:

nodemon --ext '.js|.css|.html'
nodemon -e js,css,html

Or with alternative syntax:

nodemon -e js,css,html
nodemon --ext '.js|.css|.html'

Now nodemon will restart on any changes to files in the directory (or subdirectories) with the extensions .js, .css or .html.

Expand Down
22 changes: 15 additions & 7 deletions nodemon.js
Expand Up @@ -43,8 +43,6 @@ var fs = require('fs'),
program = getNodemonArgs(),
watched = [];



// test to see if the version of find being run supports searching by seconds (-mtime -1s -print)
var testAndStart = function() {
var ready = function () {
Expand Down Expand Up @@ -178,8 +176,6 @@ watchFileChecker.verify = function() {
}
};



function startNode() {
util.log('\x1B[32m[nodemon] starting `' + program.options.exec + ' ' + program.args.join(' ') + '`\x1B[0m');

Expand Down Expand Up @@ -368,8 +364,8 @@ function startMonitor() {
}

if (files.length) {
if (restartTimer !== null) {
clearTimeout(restartTimer);
if (restartTimer !== null) {
clearTimeout(restartTimer);
}
restartTimer = setTimeout(function () {
if (program.options.verbose) {
Expand Down Expand Up @@ -775,7 +771,8 @@ if (!program.app) {
}

if (program.options.verbose) {
util.log('[nodemon] v' + meta.version);
util.log('\x1B[33m[nodemon] v' + meta.version + '\x1B[0m');
util.log('\x1B[33m[nodemon] to restart at any time, enter `rs`\x1B[0m');
}

// this was causing problems for a lot of people, so now not moving to the subdirectory
Expand Down Expand Up @@ -818,4 +815,15 @@ exists(ignoreFilePath, function (exist) {
}
});

// allow nodemon to restart when the use types 'rs\n'
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (data) {
data = (data + '').trim().toLowerCase();
if (data === 'rs') {
util.log('\x1B[32m[nodemon] restarting child process\x1B[0m');
killNode();
}
});

testAndStart();
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -9,7 +9,7 @@
"repository": { "type" : "git", "url" : "http://github.com/remy/nodemon.git" },
"description": "Simple monitor script for use during development of a node.js app.",
"keywords": ["monitor", "development", "restart", "autoload", "reload", "terminal"],
"version": "0.7.6",
"version": "0.7.7",
"preferGlobal" : "true",
"licenses": [{
"type": "MIT",
Expand Down

0 comments on commit 8ca0264

Please sign in to comment.