Forum OpenACS Q&A: Re: inittab and daemontools in Intsall Documentation

Collapse
Posted by Peter Marklund on
I err on the side of agreeing with Lamar here (i.e. keeping the inittab approach around). My own experience is that at ArsDigita I never had any problems doing OpenACS development with inittab, you carefully edit one text file, then issue a command (something like init q), then use the restart-aolserver perl script and you are off.

Working with supervise at Collaboraid on the other hand I have had *tremendeous* difficulties and frustrations. It turns out the approach is extremely sensitive to the permission in your source tree and when there is a failure it is a silent one that is hard to diagnose. If Lars hadn't been there to help me out I think I would have abandoned the approach altogether.

Therefore, I'm not sure I would recommend supervise to a beginner on a development box, unless there are some really fool proof instructions around for how to set it up. AFAIK we don't currently have those.

Collapse
Posted by Bruno Mattarollo on

I tend to agree with Lamar and Peter. We are using inittab on our production servers and we had zero problems with it so far. It's simple, convenient and when you don't need a lot of flexibility, it's the easiest solution to implement.

Just my two cents

Collapse
Posted by Oscar Bonilla on
I've used both the inittab and daemontools approaches, and I like daemontools better. I ported the restart-aolserver perl script from inittab style to daemontools style. Maybe that would be useful (the script is at the bottom).

The permission problem Peter talks about does not depend on how AOLServer was started (inittab or daemontool) but on the user as which it's running. My guess is that at ArsDigita they ran AOLServer as root (bad!) and at Collaboraid they ran it as a regular user. I'm only guessing here since ArsDigita had documentation on how to run it on a chroot environment (which I did once, but it was more painful than useful). One last thing, "init q" requires root priviledges, restarts init (unnecessary), and is also used for changing run-levels. If you setuid root init you're asking for trouble. On the other hand, "svc" does only one thing (restarts services) and even though it requires root priviledges it isn't as dangerous or prone to misuse as init. If you use the restart-aolserver script setuid root you limit the damage a regular user can do.

Daemontools is *very* simple to install and it comes as a package in most Operating Systems, in fact, it *works* in all operating systems. Inittab is a System V specific feature which is not available in the BSD's. I think the more generic approach is the daemontools approach.

Anyway, after all the blurb, here's the script:

---- cut here ----
#!/usr/bin/suidperl -Tw

use POSIX qw(strftime);

$LOGFILE = "/var/log/restart-aolserver.log";

$ENV{'PATH'} = "";

if ($#ARGV < 0) {
        print "usage: restart-aolserver <service_name>\n";
        exit(1);
}

if ( ! -d "/service/web-$ARGV[0]" ) {
        print "$ARGV[0]: service does not exist\n";
        exit(1);
}

$user = (getpwuid($<))[0];
$timestamp = strftime "%Y-%m-%d %H:%M:%S", localtime;

open(LOG, ">>$LOGFILE") || die "Could not open LogFile";
print LOG $timestamp, "\t", $user, " restarted ", $ARGV[0], "\n";
close(LOG);

print "restarting $ARGV[0]...";
system ("/usr/local/bin/svc", "-t", "/service/web-$ARGV[0]");
print "done.\n";
---- cut here ----

Regards.