New Linux distributions are using upstart framework to manage start and stop of services. Upstart does not rely on init.d-scripts anymore, but introduced a new declaration syntax to describe dependencies and requirements. Per service a single file is placed in directory /etc/init/, containing the service declaration.
STAF is the Software Testing Automation Framework, an open source, multi-platform, multi-language framework for distributed testing. Each host integrating into the test framework must execute the staf-service as background service receiving and executing commands on that host.
For Ubuntu 10.4 (Upstart based), STAF can be added to the list of system services being started during boot the following way.
We assume that STAF has been installed under directory /usr/local/staf. STAF is shipped with a startup script startSTAFProc.sh. The problem with that script is, that it starts the STAF process as detached subprocess, and terminates when done so. For upstart the script must be modified, so that upstart can keep a handle on the running service process, here STAF.
I prepared the following script /usr/local/staf/serviceSTAFProc.sh, which is sourcing the environment variables and finally replacing the shell context by the new STAF service context. The difference is subtle, but the effect is significant.
#!/bin/sh
#
# Sets up the STAF environment variables and
# replaces shell process by STAFProc process
# File: $STAF_HOME/serviceSTAFProc.sh
STAF_HOME=/usr/local/staf
. $STAF_HOME/STAFEnv.sh
exec $STAF_HOME/bin/STAFProc
This script will block until the process STRAFProc terminated. You may invoke the script on console and terminate by Ctrl-C.
An upstart configuration file (/etc/init/staf.conf) will tell upstart in which situation that STAF service is to be started.
# staf - software testing automation framework
#
# The Software Testing Automation Framework (STAF is
# an open source, multi language framework designed
# around the idea of reusable components
#
# File: /etc/init/staf.conf
#
description "software testing automation framework daemon"
start on runlevel [2345]
exec /usr/local/staf/serviceSTAFProc.sh
Now you should be able to start/stop the STAF service and query its state:
user@vmub1004c:~$ sudo initctl start staf
staf start/running, process 3173
user@vmub1004c:~$ sudo initctl status staf
staf start/running, process 3173
user@vmub1004c:~$ sudo initctl stop staf
staf stop/waiting
If you get an error message unknown job above, validate the executable-path or check for typos in the file staf.conf.