Re: How to debug why a service doesn't want to start.
Laurent Bercot <[email protected]>
| Newsgroups | gmane.comp.misc.pape.general |
|---|---|
| Message-ID | <[email protected]> |
> # cat /var/svc.d/users/wwwadmin/run > #!/bin/sh -e > > USER=`basename $PWD` > SVPATH=/home/$USER/service > > exec 2>&1 > exec chpst -u$USER runsvdir $SVPATH You're relying on the PWD environment variable. This variable has no reason to be set in a boot environment. The basename command doesn't like this, so it exits nonzero. Since you're using "/bin/sh -e" as your interpreter, your script exits as soon as a command exits nonzero. So here it exits right after the basename command, without writing anything anywhere. I haven't looked at the truss output, because it's too cluttered up with dynamic linking (guys, try to use STATIC binaries when you trace a program, so we can get directly to the point), but I'm ready to bet that it's what happens: basename exits nonzero, the shell exits. Game over. Your script works when you type "./run" because you're running it in a user environment, where the PWD environment variable is defined. You should find a more reliable way to set USER. Why not hardcode it, since the run script isn't supposed to be automatically generated? More generally, it's really important to see the difference between a boot environment and a user environment. This difference is what makes runit (and other supervision suites) more secure than System V schemes: the boot environment is always the same no matter what, and it's good for services to have that guarantee. A user environment (when you have an interactive shell) can change, and it's not reliable to start or test services from it. -- Laurent