login community faq

I have a node.js application and I use GNU Screen to keep the session alive when I log out from the server. Every now and then the app is down and I need to start it again. I guess it is simply because the server rebooted. Is there a way to lunch the app whenever the server reboots? Maybe still using GNU Screen so that I can get back to the running process?

Is what adviced here still the best approach? If so, is this script the easiest way to do so?

Thanks!

asked Oct 01 '12 at 08:34

gabon's gravatar image

gabon
52

edited Oct 02 '12 at 01:13


Yes the best approach is with a bash script that is execute via cron at a set interval:

1
2
3
4
5
6
7
if [ `ps -u USERNAME | grep -i PROCESS | wc -l` -lt 1 ]
then
    echo "Starting <PROCESS>."
    <enter the command to start your process here>
else
    echo "<PROCESS> is running."
fi

answered Oct 01 '12 at 09:55

timg's gravatar image

timg ♦♦
4714

Your answer
If you have an answer to the above question, then use the form below. Otherwise, use the appropriate 'add new comment' button above to post your feedback.
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×21
×15

Asked: Oct 01 '12 at 08:34

Seen: 618 times

Last updated: Oct 02 '12 at 01:13

Plans & prices    Sign up    Why WebFaction?    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
Powered by OSQA
© Copyright 2003-2012 Swarma Limited - WebFaction is a service of Swarma Limited