Ubuntu uses Upstart to handle starting, stopping and supervising of services. This page describes how to run Apache ServiceMix as a service on Ubuntu.
Configuring Upstart to run ServiceMix
For Upstart, every service is defined in its own file in /etc/event.d
. To add ServiceMix, just create /etc/event.d/servicemix
with the contents shown below:
# Apache ServiceMix # # Starts/stops ServiceMix when the computer starts/stops # Also restart ServiceMix after it has died unexpectedly 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 kill timeout 15 respawn exec /opt/servicemix/bin/servicemix
In this example:
- ServiceMix automatically starts/stops with the system
- a time-out of 15 seconds was configured between sending TERM and KILL signals when stopping the service, to allow ServiceMix to shut down properly
- when ServiceMix dies unexpectedly, the service will automatically be restarted by Upstart
- the default ServiceMix distribution has been extracted to
/opt/servicemix
, no modifications are required to the standard script
Using Upstart to control ServiceMix
The example above will start/stop ServiceMix automatically with the system, but you can also control the service from a command line:
sudo initctl start servicemix
starts ServiceMix manuallysudo initctl status servicemix
will show you the current status of the service, as well as the PID when runningsudo initctl stop servicemix
stops ServiceMix manually