Skip to content

upstart init daemon

On Ubuntu, upstart has replaced System-V init. Since Ubuntu 15, systemd replaced upstart.

There should be existing scripts in /etc/init/. Copy one of them and modify it to suit your needs.

Sometimes the daemon you want to run should be run as a different user. Use the start-stop-daemon command for this. In the case below the teamcity user will be running the daemon.

I’ve placed this in /etc/init/teamcity.conf

Terminal window
# Ubuntu upstart file at /etc/init/teamcity.conf
start on runlevel [2345]
stop on runlevel [06]
script
exec start-stop-daemon --start --quiet --chuid teamcity --exec /home/teamcity/TeamCity/bin/teamcity-server.sh run
end script

Test out the start-stop-daemon command manually.

Terminal window
# start-stop-daemon --start --chuid teamcity --exec /home/teamcity/TeamCity/bin/teamcity-server.sh run

If it is working fine then your script is ready. Kill the job and in the next step start it via the upstart command.

Use the start command. The name of your job must match the name of your conf file in /etc/init.

Terminal window
# start teamcity
teamcity start/running, process 7407

Reboot and check that your service automatically starts.

Use the stop command. If your job has forked upstart may have trouble stopping it.