Create systemd services for Atlassian Apps

While working with the Atlassian products over the years, a pattern emerges. Even though there are distinct differences in their setup and configurations, the installation process can be generalized. One of the post-installation considerations to make is in the manual creation of a service.  The benefit of a service is that it will automate the running of the application, rather than manual intervention. Earlier versions of CentOS 6.x and below would rely on a service created in /etc/init.d/servicename.  In CentOS 7.x, this is still possible, but it would be more beneficial in the long term to write systemd scripts. By the way, this process is not limited to Atlassian applications.  This directly applies to many Tomcat installations as well as many other applications.

Services may be found in a couple of places, the /etc/systemd/system and the /usr/lib/systemd/system directories.  Services located in the /usr/lib/systemd/system directory are “Units of installed packages” which means anything installed via an RPM. “Local configuration” or user created or modified services should go into the /etc/systemd/system directory.

I’m not going to display all of the services, just a couple.  They can easily be tailored to the other applications.

Atlassian JIRA

cat > /etc/systemd/system/jira.service << EOF
[Unit]
Description=Starts and stops Atlassian JIRA Server
After=syslog.target network.target
  
[Service]
User=jira
Group=jira
Type=forking
ExecStart=/opt/jira/bin/catalina.sh start
Restart=on-failure
RestartSec=10
  
[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl enable jira

Atlassian Fisheye

The difference between this service and the one above is the addition of the Environment directives to handle the FISHEYE_HOME and FISHEYE_INST variables.  This is easier to do than hack up the the Fisheye installation.

cat > /etc/systemd/system/fisheye.service << EOF
[Unit]
Description=Starts and stops Atlassian Fisheye Server
After=syslog.target network.target

[Service]
User=fisheye
Group=fisheye
Environment='FISHEYE_HOME=/opt/fisheye'
Environment='FISHEYE_INST=/opt/data/fisheye'
Type=forking
ExecStart=/opt/fisheye/bin/fisheyectl.sh start
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl enable fisheye

Source(s)

  • https://unix.stackexchange.com/questions/206315/whats-the-difference-between-usr-lib-systemd-system-and-etc-systemd-system
  • man systemd.unit