Introduction
This article describes the procedures to enable Mule runtime as systemd service for Mule standalone runtime clustering on-premises or in private clouds. Since RHEL 7, the systemd init system is a must. The traditional init.d approach is obsolete. For details about the systemd and Unit files, you may refer to this article.
Assumptions
- Mule standalone runtime is installed at /opt/mule/runtime/current
- Mule runtime can be started and stoped by the command /opt/mule/runtime/current/bin/mule start | stop
- mule user has sudo permission
Create Unit File
First, we need to create a file, mule.service at /etc/systemd/system, with the following contents:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | # file: /etc/systemd/system/mule.service # Systemd unit file for mule standalone runtime [Unit] Description=Mule Runtime Standalone Runtime After=syslog.target network.target [Service] Type=forking WorkingDirectory= /opt/mule/runtime/current Environment=JAVA_HOME= /usr/lib/jvm/java-1 .8.0-openjdk-1.8.0.222.b10-0.el7_6.x86_64 Environment=MULE_HOME= /opt/mule/runtime/current TasksMax=infinity LimitNOFILE=65335 ExecStart= /opt/mule/runtime/current/bin/mule start ExecStop= /opt/mule/runtime/current/bin/mule stop User=mule Group=mule RestartSec=10 Restart=always [Install] WantedBy=multi-user.target |
1 2 3 4 | $ cd /etc/systemd/system/ $ sudo chmod 644 mule.service $ sudo systemctl daemon-reload $ sudo systemctl enable mule.service |
systemd-readahead-drop.service -> /usr/lib/systemd/system/systemd-readahead-drop.serviceNow, we are ready to start the mule runtime as a service. To do this, we must first stop the running Mule runtime:
$ cd /opt/mule/runtime/current $ bin/mule stopNow, run the following command:
1 | $ sudo systemctl start mule.service |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | $ sudo systemctl status mule.service ● mule.service - Mule Runtime Standalone Runtime Loaded: loaded ( /etc/systemd/system/mule .service; enabled; vendor preset: disabled) Active: active (running) since Sat 2019-08-24 15:46:04 CDT; 2h 45min ago Main PID: 17555 (wrapper-linux-x) CGroup: /system .slice /mule .service ├─17555 /opt/mule/runtime/current/lib/boot/exec/wrapper-linux-x86-64 /opt/mule/runtime/current/conf/wrapper .conf wrapper.s... └─17569 /usr/lib/jvm/java-1 .8.0-openjdk-1.8.0.222.b10-0.el7_6.x86_64 /jre/bin/java -Dmule.home= /opt/mule/runtime/current -D... Aug 24 15:45:41 wp37mulerte01.aci.awscloud systemd[1]: Starting Mule Runtime Standalone Runtime... Aug 24 15:45:41 wp37mulerte01.aci.awscloud mule[17439]: MULE_HOME is set to /opt/mule/runtime/current Aug 24 15:45:41 wp37mulerte01.aci.awscloud mule[17439]: MULE_BASE is set to /opt/mule/runtime/current Aug 24 15:45:42 wp37mulerte01.aci.awscloud mule[17439]: Starting Mule Enterprise Edition... Aug 24 15:46:04 wp37mulerte01.aci.awscloud mule[17439]: Waiting for Mule Enterprise Edition....................... Aug 24 15:46:04 wp37mulerte01.aci.awscloud mule[17439]: running: PID:17555 Aug 24 15:46:04 wp37mulerte01.aci.awscloud systemd[1]: Started Mule Runtime Standalone Runtime. |
1 | $ sudo systemctl -l status mule.service |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | $ sudo journalctl -u mule.service -- Logs begin at Tue 2019-08-06 23:11:10 CDT, end at Sat 2019-08-24 18:39:13 CDT. -- Aug 22 21:40:03 wd35mulerte01.aci.awscloud systemd[1]: Starting Mule Runtime Standalone Runtime... Aug 22 21:40:03 wd35mulerte01.aci.awscloud mule[31293]: MULE_HOME is set to /opt/mule/runtime/current Aug 22 21:40:03 wd35mulerte01.aci.awscloud mule[31293]: MULE_BASE is set to /opt/mule/runtime/current Aug 22 21:40:05 wd35mulerte01.aci.awscloud systemd[1]: mule.service: control process exited, code=exited status=1 Aug 22 21:40:05 wd35mulerte01.aci.awscloud systemd[1]: Failed to start Mule Runtime Standalone Runtime. Aug 22 21:40:05 wd35mulerte01.aci.awscloud systemd[1]: Unit mule.service entered failed state. Aug 22 21:40:05 wd35mulerte01.aci.awscloud systemd[1]: mule.service failed. Aug 22 21:40:14 wd35mulerte01.aci.awscloud systemd[1]: Stopped Mule Runtime Standalone Runtime. Aug 22 21:52:39 wd35mulerte01.aci.awscloud systemd[1]: Starting Mule Runtime Standalone Runtime... Aug 22 21:52:39 wd35mulerte01.aci.awscloud mule[32610]: MULE_HOME is set to /opt/mule/runtime/current Aug 22 21:52:39 wd35mulerte01.aci.awscloud mule[32610]: MULE_BASE is set to /opt/mule/runtime/current Aug 22 21:52:40 wd35mulerte01.aci.awscloud mule[32610]: Starting Mule Enterprise Edition... Aug 22 21:53:03 wd35mulerte01.aci.awscloud mule[32610]: Waiting for Mule Enterprise Edition......................... Aug 22 21:53:04 wd35mulerte01.aci.awscloud mule[32610]: running: PID:32750 Aug 22 21:53:04 wd35mulerte01.aci.awscloud systemd[1]: Started Mule Runtime Standalone Runtime. Aug 22 21:54:15 wd35mulerte01.aci.awscloud systemd[1]: Stopping Mule Runtime Standalone Runtime... Aug 22 21:54:15 wd35mulerte01.aci.awscloud mule[633]: MULE_HOME is set to /opt/mule/runtime/current Aug 22 21:54:15 wd35mulerte01.aci.awscloud mule[633]: MULE_BASE is set to /opt/mule/runtime/current Aug 22 21:54:15 wd35mulerte01.aci.awscloud mule[633]: Stopping Mule Enterprise Edition... Aug 22 21:54:18 wd35mulerte01.aci.awscloud systemd[1]: Stopped Mule Runtime Standalone Runtime. Aug 22 21:55:43 wd35mulerte01.aci.awscloud systemd[1]: Starting Mule Runtime Standalone Runtime... Aug 22 21:55:44 wd35mulerte01.aci.awscloud mule[912]: MULE_HOME is set to /opt/mule/runtime/current Aug 22 21:55:44 wd35mulerte01.aci.awscloud mule[912]: MULE_BASE is set to /opt/mule/runtime/current Aug 22 21:55:45 wd35mulerte01.aci.awscloud mule[912]: Starting Mule Enterprise Edition... Aug 22 21:56:08 wd35mulerte01.aci.awscloud mule[912]: Waiting for Mule Enterprise Edition......................... Aug 22 21:56:08 wd35mulerte01.aci.awscloud mule[912]: running: PID:1091 Aug 22 21:56:08 wd35mulerte01.aci.awscloud systemd[1]: Started Mule Runtime Standalone Runtime. |
That is it. It is very helpful to study the commands of systemctl and journalctl.