Skip to content

Instantly share code, notes, and snippets.

@curiositycasualty
Forked from elmariofredo/teamcity-agent.service
Last active January 18, 2019 19:45
Show Gist options
  • Save curiositycasualty/5fd60c3f0e830b15465a279ffe18cbf6 to your computer and use it in GitHub Desktop.
Save curiositycasualty/5fd60c3f0e830b15465a279ffe18cbf6 to your computer and use it in GitHub Desktop.
systemd service files for running TeamCity (create in /usr/lib/systemd/system)
[Unit]
Description=TeamCity Build Agent
After=network.target
[Service]
Type=forking
RemainAfterExit=yes
User=teamcity
Group=users
PIDFile=/opt/teamcity-agent/logs/buildAgent.pid
Environment="JAVA_HOME=/usr/java/latest"
ExecStart=/opt/teamcity-agent/bin/agent.sh start
ExecStop=/opt/teamcity-agent/bin/agent.sh stop
# agent will exit w/ 143 during upgrade process
SuccessExitStatus=143 0
[Install]
WantedBy=multi-user.target
[Unit]
Description=TeamCity Server
After=network.target
[Service]
Type=forking
Environment="JAVA_HOME=/usr/java/latest"
Environment=TEAMCITY_DATA_PATH=/data
Environment=TEAMCITY_SERVER_MEM_OPTS='-Xms4g -XX:ReservedCodeCacheSize=1g'
Environment=TEAMCITY_SERVER_OPTS=
Environment=CATALINA_OPTS='-Dhttps.protocols=TLSv1.2 -Djdk.tls.client.protocols=TLSv1.2 -Duser.timezone=America/Los_Angeles -Djava.awt.headless=true'
Environment=CATALINA_TMPDIR=/data/tmp
# default pid file location (as of 2018.x at least)
PIDFile=/opt/teamcity-server/logs/teamcity.pid
User=teamcity
Group=users
# running w/ 'User=' here only works if using ports 1024 > in server.xml
ExecStart=/opt/teamcity-server/bin/teamcity-server.sh start
ExecStop=/opt/teamcity-server/bin/teamcity-server.sh stop
# another option is the tomcat-ism:
# ExecStart=/opt/teamcity-server/bin/teamcity-server.sh start <user>
# ExecStop=/opt/teamcity-server/bin/teamcity-server.sh stop <user>
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment