We talk about JavaScript. Each month in Warsaw, Poland.
I found myself doing all those repetetive actions and facing the same problems with Node for years.
Turns out, most of them are easly solved by existing tools.
I didn't know that such tools exists... So I haven't search for them.
$ npm install -g nodemon
// $ node myapp.js
$ nodemon myapp.js
// run with arguments
$ nodemon myapp.js --port 80
// ignore files or directories, that can change
$ nodemon --ignore tests/ myapp.js
// watch only specyfic directories
$ nodemon --watch app/ --watch node_modules/ myapp.js
// run non-node scripts
$ nodemon --exec "python -v" ./myapp.py
// delay the restarts by 3 seconds
$ nodemon --delay 3 myapp.js
$ npm install -g node-inspector // duh...
$ node-debug myapp.js
// create web-inspector server
$ node-inspector
// use node's native debug protocol to connect
$ node --debug myapp.js
// save live edit
$ node-debug --save-live-edit myapp.js
// install any version
$ nvm install 0.12.9
// switch to that version
$ nvm use 0.12.9
// run your app in different version
$ nvm run 0.12.9 myapp.js
// run shell command with different node version
$ nvm exec 0.12.9 node myapp.js
// run your app
$ pm2 start myapp.js
// run in 5 instances
$ pm2 start myapp.js -i 5
// restart after exceeding 1GB
$ pm2 start myapp.js --max-memory-restart 1024M
pm2 list
pm2 monit
var httpProxy = require('http-proxy');
httpProxy.createServer({
hostnameOnly: true,
router: {
'domain1.com': '127.0.0.1:3001',
'domain2.com': '127.0.0.1:3002'
}
}).listen(80);