-
Notifications
You must be signed in to change notification settings - Fork 9
README
shimondoodkin edited this page Sep 14, 2010
·
11 revisions
It is a way to watch all .js files if they have been changed and to restart nodejs.
It allows easy development and stable production.
Copy autoexit.js and nodejs.sh to /var/www/
require.paths.unshift(__dirname); //make local paths accecible
require('autoexit');
try
{
//your code
}
catch(e)
{
sys.puts(e.stack)
}
require.paths.unshift(__dirname); //make local paths accessible
var sys = require('sys'),
http = require('http');
http.createServer(function (req, res) {
try
{
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}
catch(e)
{
sys.puts(e.stack);
}
}).listen(8124, "127.0.0.1");
sys.puts('Server running at http://127.0.0.1:8124/');
require('autoexit');
Edit `nodejs.sh` to match to your server.js filename.
cd /var/www
./nodejs.sh
To make it work with upstart
Copy `nodejs.conf` to `/etc/init/`
[command] + [init filename without conf extention]
start nodejs
stop nodejs
restrt nodejs
stop nodejs
cd /var/www
./nodejs.sh
Then I will start to see application output and errors on the screen
If I want to stop the server I press `Control + C`
and the script stops.
Modify autoexit.js for your needs to watch other folders and file types