You should run nodejs as daemon.
http://blog.nodejitsu.com/keep-a-nodejs-server-up-with-forever
--
regards,
Prashanth
twitter: munichlinux
irc: munichlinux, JSLint, munichpython.
That is probably one of the worst links you could point someone at, it
does introduce
a practice which is only acceptable when one knows what they are doing.
Namely that is: "when it crashed, just restart!"
Anyone should first make all possible effort to design their program
properly and debug
all they can possibly debug. The kind of tools you are pointing people
at are only good
for dealing with a production situation where they code could be
crashing due to some
very very obscure bug and production environment just needs a quick
aid until the bug
is found and fixed.
For a beginner the simplest and guaranteed to work approach would to
use `nohup`.
Other approaches are going to be all platform dependent. Well, the
original question
mentions that they are using Ubuntu, there one could use Upstart as
specified here:
http://howtonode.org/deploying-node-upstart-monit
But that example uses /etc/init/ directory, in fact on Ubuntu one can
put Upstart scripts
in ~/.init/ and should be able to run those without root previlages
and without doing sudo
in the script itself. Also, if you do read the above guide - the
second section on Monit is
not quite the best thing you can do with it ...
Cheers,
--
Ilya
@Angelo Chen:
Clearly the person in question does not understood what you said.
@jeeee:
When you ran your http server in your shell, it was attached to the
shell. This is not node.js related. You have to find a way of running
your server detached from your shell. One possible way is running
screen program. Warning: this might get confusing
> Installing screen:
sudo apt-get install screen
man screen
(read it until you're more or less confortable)
> Creating a screen:
screen
(or)
screen -S <some_name>
(both will get you inside a screen)
> Get out of a screen (leaving it running 24/7):
Ctrl+a (and then) d (which means detach)
> Listing running screens:
screen -ls
> Reopening a screen (that you detached early):
screen -dr <id_from_the_previous_command>
(or)
screen -dr <some_name>
(-dr = detach anyone in the screen and reattach screen on my shell)
> Close a screen:
Just stop anything you have running in the screen and exit
the shell by typing exit or Ctrl+d
There is a lot more you can do but I advise you to read some from the
man page, then play with it and then come back to the man page.
---
Diogo R.
A good (temporary) solution:
$ node server.js &
$ disown %1
$ exit
The `&` tells the shell to run node in the background. It will say
something like "[1] 1233," which means that the node process has pid
1233 and is job #1. Then, you disown the job and exit the shell. The
node process will continue to run in the background.
--
Ryan Doenges
does not need to be any more complicated than this....
-Karl Tiedt
Start node in background and redirect stdout and stderr to log-files:
nohup node blah.js > output.log 2> error.log < /dev/null &
And to redirect only stderr to a log-file:
nohup node blah.js > /dev/null 2> error.log < /dev/null &
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+un...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en