Add confluence to systemd

I really think that confluence is a great, simple and cheap tool to keep documentation about IT departments in companies, personal projects or whatever. If you manage a self-hosted one, you probably ask yourself some times: Why this guys still don’t use systemd??

I ask myself this question a lot of times, so… let’s configure it.

First of all we must create the systemd file and set it the right permissions.

root@labo1234:~ $ touch /lib/systemd/system/confluence.service
root@labo1234:~ $ chmod 664 /lib/systemd/system/confluence.service

Then edit this file like that (for a confluence default installations).

[Unit]
Description=Confluence
After=network.target

[Service]
Type=forking
User=confluence
PIDFile=/opt/atlassian/confluence/work/catalina.pid
ExecStart=/opt/atlassian/confluence/bin/start-confluence.sh
ExecStop=/opt/atlassian/confluence/bin/stop-confluence.sh
TimeoutSec=200
LimitNOFILE=4096
LimitNPROC=4096

[Install]
WantedBy=multi-user.target

If your OS user is not called “confluence” or your confluence path is not “/opt/atlassian/confluence” you must edit the file with your right values.

Also, about the “Limit*” parameters, remember that systemd ignores system ulimits. The values will need to be specified in the proper service file .service.

Then reload the systemd daemon

root@labo1234:~ $ systemctl daemon-reload

Enable the confluence service

root@labo1234:~ $ systemctl enable confluence.service
Created symlink from /etc/systemd/system/multi-user.target.wants/confluence.service to /usr/lib/systemd/system/confluence.service.
root@labo1234:~ $ 

Start & check the service

root@labo1234:~ $ systemctl start confluence.service
root@labo1234:~ $ systemctl status confluence.service
● confluence.service - Confluence
   Loaded: loaded (/usr/lib/systemd/system/confluence.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2019-02-27 09:27:56 CST; 4s ago
  Process: 5464 ExecStart=/opt/atlassian/confluence/bin/start-confluence.sh (code=exited, status=0/SUCCESS)
 Main PID: 5522 (java)
   CGroup: /system.slice/confluence.service
           └─5522 /opt/atlassian/confluence/jre//bin/java -Djava.util.logging.config.file=/opt/atlassian/confluence/conf/logging.properties -Djava.util.logging.manage...

Feb 27 09:27:55 labo1234 start-confluence.sh[5464]: executing as current user
Feb 27 09:27:55 labo1234 start-confluence.sh[5464]: If you encounter issues starting up Confluence, please see the Installation guide at http://con...on+Guide
Feb 27 09:27:55 labo1234 start-confluence.sh[5464]: Server startup logs are located in /opt/atlassian/confluence/logs/catalina.out
Feb 27 09:27:55 labo1234 start-confluence.sh[5464]: ---------------------------------------------------------------------------
Feb 27 09:27:55 labo1234 start-confluence.sh[5464]: Using Java: /opt/atlassian/confluence/jre//bin/java
Feb 27 09:27:56 labo1234 start-confluence.sh[5464]: 2019-02-27 09:27:56,430 INFO [main] [atlassian.confluence.bootstrap.SynchronyProxyWatchdog] A C...required
Feb 27 09:27:56 labo1234 start-confluence.sh[5464]: ---------------------------------------------------------------------------
Feb 27 09:27:56 labo1234 start-confluence.sh[5464]: Existing PID file found during start.
Feb 27 09:27:56 labo1234 start-confluence.sh[5464]: Removing/clearing stale PID file.
Feb 27 09:27:56 labo1234 systemd[1]: Started Confluence.
Hint: Some lines were ellipsized, use -l to show in full.
root@labo1234:~ $