Running Mule With Systemd

Most modern Linux distributions now uses systemd as the init system. However the official documentation for Mule Standalone Runtime currently (2017-06-19) only describes how to use the old SystemV init script style to run the Mule Standalone Runtime as a Unix Daemon.

Used software: Mule Standalone Runtime 3.8.4 EE, OpenJDK 1.8, RedHat Enterprise Linux 7

Most modern Linux distributions now uses systemd as the init system. However the official documentation for Mule Standalone Runtime currently (2017-06-19) only describes how to use the old SystemV init script style to run the Mule Standalone Runtime as a Unix Daemon.

Here is a quick guide on how to create a systemd Unit file for a Mule Standalone Runtime service. These instructions was created for and tested on a RedHat Enterprise Linux 7 server. However most should be applicable to other Linux distros running systemd.

  1. Make sure your machine fulfills the standard Mule pre-requisites. Such as has Java 8 installed. This guide assumes they are installed using the official packages from the distribution.
  2. Add a mule user
    root@server:~# adduser -r mule
  3. Unpack the Mule distribution into /opt
1
2
root@server:~# cd /opt 
root@server:~# unzip /tmp/mule-ee-distribution-standalone-3.8.4.zip
  1. Create a symlink to the mule directory and fix privileges
1
2
3
root@server:~# ln -s mule-enterprise-standalone-3.8.4 mule
root@server:~# chown -R mule:mule mule-enterprise-standalone-3.8.4
root@server:~# chmod  -R o-w mule-enterprise-standalone-3.8.4
  1. Create the a mule unit file
1
2
root@server:~# touch /etc/systemd/system/mule.service
root@server:~# chmod 664 /etc/systemd/system/mule.service
  1. Add the following content to the file using your favorit editor
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Systemd unit file for mule standalone runtime
[Unit]
Description=Mule Runtime Standalone Runtime
After=syslog.target network.target

[Service]
Type=forking
WorkingDirectory=/opt/mule
Environment=JAVA_HOME=/usr
Environment=MULE_HOME=/opt/mule
TasksMax=infinity 
LimitNOFILE=65335

ExecStart=/opt/mule/bin/mule start
ExecStop=/opt/mule/bin/mule stop

User=mule
Group=mule

RestartSec=10
Restart=always

[Install]
WantedBy=multi-user.target
  1. Reload the systemd configuration
1
root@server:~# systemctl daemon-reload
  1. Start the service to test that it starts up correctly
1
root@server:~# systemctl start mule.service
  1. Enable the service so that it is started by default at boot
1
root@server:~# systemctl enable mule.service
  1. Reboot the server to verify that the service comes up as expected