2

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.

Scott Klarenbach
  • 569
  • 2
  • 8
  • 20

2 Answers2

7

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

Mark Wagner
  • 18,019
  • 2
  • 32
  • 47
  • 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 Klarenbach Jul 06 '11 at 16:46
2

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.

Zoredache
  • 130,897
  • 41
  • 276
  • 420
  • 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 Klarenbach Jul 06 '11 at 16:35