upstart init daemon
On Ubuntu, upstart has replaced System-V init. Since Ubuntu 15, systemd replaced upstart.
Adding a new daemon or service
Section titled “Adding a new daemon or service”Create your script
Section titled “Create your script”There should be existing scripts in /etc/init/. Copy one of them and
modify it to suit your needs.
Changing uid
Section titled “Changing uid”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
# 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 runend scriptTest your command
Section titled “Test your command”Test out the start-stop-daemon command manually.
# start-stop-daemon --start --chuid teamcity --exec /home/teamcity/TeamCity/bin/teamcity-server.sh runIf it is working fine then your script is ready. Kill the job and in the next step start it via the upstart command.
Start the job
Section titled “Start the job”Use the start command. The name of your job must match the name of your conf file in /etc/init.
# start teamcityteamcity start/running, process 7407Reboot
Section titled “Reboot”Reboot and check that your service automatically starts.
Stopping the job
Section titled “Stopping the job”Use the stop command. If your job has forked upstart may have trouble stopping it.