At 2005-01-21T11:17:31+1300, Andrew Errington wrote:

> a) Run automatically when the server is rebooted (with a current
> uptime of 228 days I am loathe to test that...)

Take a look at the skeleton script in /etc/init.d/skeleton for a basic
Debian-style init script.  Once you've created the appropriate init
script(s), link them into the runlevel startup directories as
appropriate using update-rc.d(8).  Make sure you use
start-stop-daemon(8), because it already performs a lot of the work you
need to do.

To do it properly, you should look at modifying your programs so that
they daemonize themselves and drop all unneeded privileges.

> b) Restart automatically if they ever stop running

You have to be careful doing this so that you don't get into a situation
where the program dies immediately and ends up in a tight respawning
loop.  You also have to make sure your program safely handles any
previous unclean terminations.

If the programs are relatively stable, you shouldn't need to
automatically restart them on failure, because failures will be rare and
usually suggestive of a serious problem.

> I am sure there are a number of common techniques for this, but is
> there a 'best' one?  Should the programs run as root, or run as me?

Does it _need_ to run as root?  It's extremely likely that it doesn't,
so don't run it as root.  Create a new unprivileged user with logins
disabled, the shell set to /bin/false, etc.

Cheers,
-mjg
-- 
Matthew Gregan                     |/
                                  /|                [EMAIL PROTECTED]

Reply via email to