P
P
Pshon2011-12-15 17:48:29
bash
Pshon, 2011-12-15 17:48:29

How to run a nodejs application correctly

The essence of the question is how to start the process (script) on the server.
The $node/path/main.js option doesn't roll as the process must always be running.
There is another option: use a supervisor. But it seems to me bone.
Use start-stop-daemon? there is a problem with require in scripts (apparently it is not possible to find the path to the modules that are installed for this project)

So how to “daemonize” a nodejs script?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
pomeo, 2011-12-15
@Pshon

works fine for me via supervisord
/etc/supervisor/conf.d/site.conf
[program:site]
command=/usr/local/bin/node app.js
directory=/var/www/site.com/www/current/
user=nobody
autostart=true
autorestart=true
startretries=3
stdout_logfile=/var/www/site.com/www/shared/log/server.log
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=10
stderr_logfile=/var/www/site.com/www/shared/log/error.log
stderr_logfile_maxbytes=1MB
stderr_logfile_backups=10
stopsignal=TERM
environment=NODE_ENV=production

Y
Yuri Shikanov, 2013-01-15
@dizballanze

I am using the forever module - github.com/nodejitsu/forever

E
Eugene, 2011-12-15
@Nc_Soft

Tell me how to execute a Java script code not from a file, but from a string, from a file just
node ~/test.js
you need something like node -??? 'console.log(1);'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question