Upstart questions.
Josef Wolf
jw at raven.inka.de
Wed Sep 26 22:43:37 UTC 2007
Hello,
I started migrating one of my deamons to upstart. I want to have
multiple instances (with different configuration files) to run
simultanously. The instances should be respawned when they exit.
Since this scenario is pretty close to the getty program, I started
by copying /etc/event.d/tty1 to /etc/event.d/myserver1. This is what
I have come up with so far:
jw at dvb1:~$ cat /etc/event.d/myserver1
# dvbserver1
start on runlevel 2
start on runlevel 3
start on runlevel 4
start on runlevel 5
stop on runlevel 0
stop on runlevel 1
stop on runlevel 6
respawn
exec /usr/local/bin/myserver -C /etc/myserver.d/myserver1
This setup works as expected, thus far. But I am still not sure I
make the best use use of the upstart functionality:
- Since I need several instances, it would be handy to have a variable
indicating the name of the service (that is, the filename without the
path). With this, it would be possible to write something like
exec /usr/local/bin/myserver -C /etc/myserver.d/$0
and just create hardlinks/symlinks to get additional instances.
For my use case, it is not a big deal, since my files are created
automatically anyway. But when files are maintaned manually, I think
it would be handy.
- When new files in /etc/event.d are created, or existing files are
modified, upstart seems not to notice the change. I know I can
"initctl start myserverX" after creating/modifying
/etc/event.d/myserverX. But I don't really like that because it
would lead to all sorts of racing conditions. I'd rather see
upstart to notice changes (create/delete/modify) in /etc/event.d
and react properly according to current "state" of all events.
- To make sure my server can run properly, I need to make sure a
specific module is loaded. Currently, I "modprobe mymodule" in
/etc/init.d/boot.local. I guess this would be a good use of
upstart's pre-start script. But with this, the modprobe would
be executed for every (re)spawn of every myserver instance.
While this should not do any harm, it seems to be somewhat
suboptimal.
Thanks in advance for any suggestions!
More information about the ubuntu-users
mailing list