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.

TIP

The steps given here are advanced and optional. This section can be skipped.
The following additional steps can be followed to set up a daemon for the TeamCity server:
  1. 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 simple init script for the server. This script allows you (and the system) to start and stop the server. The server is run under the teamcity user in this case.
  2. Make sure that this file is made executable. This can be done with the following command:
    chmod +x /etc/init.d/teamcity-server
    
  3. The new init script needs to be enabled, which is done with the following command:
    update-rc.d teamcity-server defaults
    
  4. TeamCity server will now be started automatically once the system is restarted, and it will run as a daemon.
  5. 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

Popular posts from this blog

HAproxy logging

teamcity Automatic Agent Start under Linux

NFS mount add in fstab _netdev instead of default | firewall-cmd --list-all