Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a RingoJS webserver (runs atop Jetty) that is part a an Apache reverse proxy setup.

I would like multiple Ringo processes to run autonomously in the background, startup automatically on reboot, etc. Basically, the same as Apache or Postgresql daemons would do.

I've investigated running processes in the background (via & or bg), nohup, and using screen to maintain multiple contexts. I'm not sure what the best practice here is.

I'd like to be able to easily identity (friendly name) each RingoJS process that is running. (one for each app). Then be able to start and stop them easily the way one does with apachectl or something. I'd like the processes to automatically startup on reboot, and not be affected by repeated ssh sessions.

Screen seems like a good choice but it's use case seems more for porting shell contexts then it does for maintaining long running system processes. I can run jobs in the background, but worry about zombie processes after logging out or cryptic PIDs that don't clearly identify which app/service is running.

Can anyone provide some pointers as to what I "should" be doing to achieve this outcome?

Thanks.

share|improve this question

2 Answers 2

up vote 7 down vote accepted

You should be creating an init service. Ubuntu uses upstart. http://upstart.ubuntu.com/

share|improve this answer
    
Thanks embobo, see my comment below to zoredache. –  Scott Jul 6 '11 at 16:36
    
I guess Upstart is basically just the newer way of doing what used to be done via manual init.d scripts. Provides dependencies, etc. So a combination of upstart and monit should be what I'm looking for. –  Scott Jul 6 '11 at 16:46

For applications that do not have a built in method for running as a deamon, you would probably want to use the start-stop-daemon command within a init/upstart script you create to start the application. You can use start-stop-daemon to start something in the background, it can log the pid to the filesystem so it can stop the process when the time comes.

Just look in /etc/init.d/ for lots of examples, specifically checkout /etc/init/skeleton for a template. Many of the existing startup scripts use start-stop-daemon. Including ssh, ntp, rsync, and many others.

share|improve this answer
    
Thanks Zoredache, I'm looking into this, but as I understand it upstart in the previous answer is basically doing this for me, but in an easier to configure manner? I'm looking into Monit as well, but am still unsure as to whether I should use Upstart and Monit or just /etc/init.d/scripts and Monit. –  Scott Jul 6 '11 at 16:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.