init.d Running the TeamCity server as a daemon
Running the TeamCity server as a daemon
The previous steps are good for running the TeamCity server (and agent) manually using the provided scripts. It is often necessary and convenient to have the server start up automatically once the machine has restarted.
The following additional steps can be followed to set up a daemon for the TeamCity server:
- Create the file
/etc/init.d/teamcity-server
with the following contents:#!/bin/bash USER=teamcity BASE=/opt/TeamCity SCRIPT=$BASE/bin/teamcity-server.sh case "$1" in start) su -l $USER -c "$SCRIPT start" ;; stop) su -l $USER -c "$SCRIPT stop" ;; *) echo "Usage: teamcity-server start|stop" exit 3 esac
The previous script is a simpleinit
script for the server. This script allows you (and the system) to start and stop the server. The server is run under theteamcity
user in this case. - Make sure that this file is made executable. This can be done with the following command:
chmod +x /etc/init.d/teamcity-server
- The new
init
script needs to be enabled, which is done with the following command:update-rc.d teamcity-server defaults
- TeamCity server will now be started automatically once the system is restarted, and it will run as a daemon.
- If needed, the server can be started and stopped by running
/etc/init.d/teamcity-server start
and/etc/init.d/teamcity-server stop
respectively.
Comments
Post a Comment