Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to write an init.d script for start_server and starman?

I'm trying to come up with a nice init.d script that starts a psgi app, using start_server and starman. It needs to have the following features:

  • Run on RedHat (i.e. Debian's start-stop-daemon is not available)
  • Run start_server as another user
  • Be maintainable.

Ideally, I'd like to use the stuff that comes with /etc/init.d/functions to give the script the look and feel of any ol' RedHat init.d script.

More specifically, I'm looking for best practices to:

  • Daemonize a program that doesn't come with its own --daemonize option
  • Run the daemon under another UID.
like image 675
innaM Avatar asked Apr 28 '13 11:04

innaM


1 Answers

You could try runit, it's another supervisor. Nowdays it seems a good practice to use one of these things. Here you could read a comparison of different supervisors.

Best practices:

  • Daemonize a program that doesn't come with its own --daemonize option

You don't have to daemonize the program, runit takes care of it.

  • Run the daemon under another UID.

Here you could use chpst

like image 121
pasja Avatar answered Oct 13 '22 16:10

pasja