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-serverwith 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 esacThe previous script is a simpleinitscript for the server. This script allows you (and the system) to start and stop the server. The server is run under theteamcityuser 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
initscript 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 startand/etc/init.d/teamcity-server stoprespectively.
Comments
Post a Comment