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.
- 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
1
2
| 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
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
|
- 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
|
- 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
|
- Reload the systemd configuration
1
| root@server:~# systemctl daemon-reload
|
- Start the service to test that it starts up correctly
1
| root@server:~# systemctl start mule.service
|
- Enable the service so that it is started by default at boot
1
| root@server:~# systemctl enable mule.service
|
- Reboot the server to verify that the service comes up as expected