← Back to front page

Managing Confluence as a service with systemd

There is a major change in service management coming up in Linux, where traditional System V init will be replaced by a modern alternative, called systemd.

With Red Hat moving to systemd in Red Hat Enterprise Linux 7 (see for example) and Debian finally settling on systemd as an init system the need to properly implement service management for Atlassian applications using systemd is becoming more substantial.

In comparison to traditional SysV init scripts, systemd offers a far more concise way to define how services should be started. In its most bare form, a systemd unit file can consist of around a dozen configuration lines which define how the service is started. This is in stark contrast to around 100-200 lines of shell code traditional init scripts consist of. For simple applications, creating an unit file is a trivial task if you know how to start and stop your application (ie. which commands to use). For a quickstart on system unit files, see Lennart Poettering’s excellent discussion on basics of unit files in his blog here.

The easiest solution to implement a service file for Confluence would be one that would use start-confluence.sh as ExecStart and stop-confluence.sh as ExecStop. However, systemd developers and the community consider this type of unit files kludgy and discourage implementation of unit files this way.  A good, quite passionate discussion relating to implementing a proper unit file for Tomcat can be read in Red Hat’s Bugzilla, in ticket 842346.

I consider the implementation done in Fedora 20 pretty good (this is the solution described by the above Bugzilla ticket), and have based my solution of top of it. There are a few shortcomings in the Fedora’s solution I wanted to address, namely inability to restart the service after failure (due to missing ability to track PID file) and an unhandy convention for placing Tomcat files under /var/lib/tomcats which does not suit well for everyone’s file system layout.

My solution can be downloaded from: http://jussiha.staff.ambientia.fi/downloads/confluence-tomcat-systemd.zip , place files in directory libexec to /usr/libexec/ambtomcat, the sysconfig/confluence file to /etc/sysconfig and system/confluence.service to /etc/systemd/system. All configuration related to service (JAVA_OPTS etc.) is done in /etc/sysconfig/confluence, which means that the traditional way of configuring  Tomcat startup parameters via setenv.sh is not utilized at all. If you are not using Fedora 20, you also need the file /usr/share/java-utils/java-functions from package javapackages-tools to use this solution. To get the file, see the Fedora package sources here.

Review both the sysconfig and the service file so that the file paths reflect your installation. After you are done, Confluence can be started by invoking systemctl start confluence. Review that the startup works by using journalctl –f –u confluence.service

Leave a Reply

  • (will not be published)

Time limit is exhausted. Please reload CAPTCHA.

Please, leave us a message and we'll contact you.
You can also contact our Service Desk by phone +358 290 010 500 or email servicedesk@ambientia.fi.