Installing WSO2 carbon based products as a Linux systemd service

Installing WSO2 carbon based products as a Linux systemd service

The WSO2 documentaton contains an example on how to install WSO2 carbon based servers as a Linux System V init service. Modern Linux systems use systemd as their init system instead of the System V style though.

The below systemd unit configuraton file named “wso2esb.service” contains the configuration to manage a WSO2 carbon based ESB server, together with the rationale of the various settings and usage instructions. This unit file can also be used for other carbon based WSO2 products such as Identity Server, Data Services Server, Data Analytics Server,… by simply replacing the name, absolute paths and other ESB references.

This configuration file was tested on Ubuntu 16.04. Small modifications may be required on other Linux distros, but in general it should work on all distros.

# For usage with systemd
# On Ubuntu:
# install by running sudo systemctl enable <absolute path>/wso2esb.service
# start by running sudo systemctl start wso2esb.service
# stop by running sudo systemctl stop wso2esb.service
# check status by running systemctl status wso2esb.service

[Unit]
Description=WSO2 ESB
# If network requirement is not specified, the esb can slow down shutdown
# of the system because of timeouts towards the RDBMS running on another
# server or other dependent remote components.
Requires=network-online.target
After=network-online.target

[Service]
# The Type=simple approach is not safe: if a user starts the server using the 
# wso2server.sh script, systemd doens't know about it and another instance will
# be started when 'systemctl start wso2esb' is executed if the server is still running.
# Type=simple
# ExecStart=CARBON_HOME/bin/wso2server.sh

Environment="JAVA_HOME=/usr/lib/jdk1.8.0_111"
# Can optionally be set, but the wso2server.sh script determines it automatically
# Cannot be used within this unit file for variable substitution
# CARBON_HOME = /opt/wso2/wso2esb/wso2esb-5.0.0

Type=forking
# Use WSO2 PID file -> this allows to still use wso2server.sh start|stop commands
# directly from command line in combination with systemctl. 'Systemctl status' will
# not detect that wso2server.sh start has been executed directly, but will correctly
# stop the server when the system is shutdown or 'systemctl stop' is executed. Systemctl
# will also not start another instance of the server when 'systemctl start' is executed.
PIDFile=/opt/wso2/wso2esb/wso2esb-5.0.0/wso2carbon.pid
ExecStart=/opt/wso2/wso2esb/wso2esb-5.0.0/bin/wso2server.sh start
ExecStop=/opt/wso2/wso2esb/wso2esb-5.0.0/bin/wso2server.sh stop
User=wso2

[Install]
WantedBy=multi-user.target
No Comments

Sorry, the comment form is closed at this time.