Running Mule with systemd
Posted by Pontus Ullgren on Monday, 19 June 2017
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.
- 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.
- Add a mule user
root@server:~# adduser -r mule
- Unpack the Mule distribution into /opt
root@server:~# cd /opt
root@server:~# unzip /tmp/mule-ee-distribution-standalone-3.8.4.zip
- Create a symlink to the mule directory and fix privileges
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
- Create the a mule unit file
root@server:~# touch /etc/systemd/system/mule.service
root@server:~# chmod 664 /etc/systemd/system/mule.service
- Add the following content to the file using your favorit editor
# 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
- Reload the systemd configuration
root@server:~# systemctl daemon-reload
- Start the service to test that it starts up correctly
root@server:~# systemctl start mule.service
- Enable the service so that it is started by default at boot
root@server:~# systemctl enable mule.service
- Reboot the server to verify that the service comes up as expected
Tags: