gulp-develop-server
run your node.js server and automatically restart with gulp.
gulp-develop-server is a development assistant for node.js server that runs the process and automatically restarts it when a file is modified.
installation
npm install gulp-develop-server --save-dev
usage
var gulp = server = ; // run servergulp; // restart server if app.js changedgulp;
api
server.listen( options[, callback] )
options {Object}
-
path
- type: {String}
- example:
'./your_node_app.js'
- Your node application path. This option is required.
-
env
- type: {Object}
- default:
{ NODE_ENV: 'development' }
(extends currentprocess.env
) - example:
{ PORT: 3000, NODE_ENV: 'production' }
- Environment settings of your server.
-
args
- type: {Array}
- your application's arguments
-
execArgv
- type: {Array}
- example:
[ '--harmony' ]
- Run node process with this options.
-
delay
- type: {Number}
- default:
600
- If this plugin does not receive an error from the server after
options.delay
seconds, assumes the server listening success. - This option needs to adjust according to your application's initialize time.
- If this option set
0
, it will only checksuccessMessage
.
-
successMessage
- type: {RegExp}
- default:
/^[Ss]erver listening/
- If your application send the specific message by
process.send
method, this plugin assumes the server listening success.
-
errorMessage
- type: {RegExp}
- default:
/[Ee]rror:/
- If this plugin receives the specific error message that matched this RegExp at start-up, assumes the server has error.
-
killSignal
- type: {String}
- default:
SIGTERM
callback( error )
server.restart( [callback] ) / server.changed( [callback] )
callback( error )
server( [options] )
Create a Transform
stream.
Restart the server at once when this stream gets files.
server.kill( [signal, callback] )
Send kill signal to the server process.
signal {String}
callback( error )
server.reset( [signal, callback] )
Send kill signal to the server process and reset the options to default.
signal {String}
callback( error )
more examples
gulp-livereload:
withvar gulp = server = livereload = ; var options = path: './apps/app.js'; var serverFiles = './apps/app.js' './routes/*.js'; gulp; // If server scripts change, restart the server and then livereload.gulp;
BrowserSync:
withvar gulp = server = bs = ; var options = server: path: './apps/app.js' execArgv: '--harmony' bs: proxy: 'http://localhost:3000' ; var serverFiles = './apps/app.js' './routes/*.js'; gulp; // If server scripts change, restart the server and then browser-reload.gulp; gulp;
use as a stream:
var gulp = server = bs = coffee = ; var options = server: path: './apps/app.js' execArgv: '--harmony' bs: proxy: 'http://localhost:3000' ; var serverCoffee = './src/*.coffee'; gulp; // If server side's coffee files change, compile these files,// restart the server and then browser-reload.gulp; gulp;