Systemctl for JBoss in RHEL7

1) Prepare file /etc/systemd/system/jboss.service

[Unit]
Description=JBoss Startup
After=multi-user.target

[Service]
User=jboss
Group=jboss
ExecStart=/appl/jboss/bin/standalone.sh -b myhost.mycompany.com
ExecStop=/appl/jboss/bin/jboss-cli.sh –controller=:9999 –connect shutdown
Restart=no

[Install]
WantedBy=multi-user.target

 

2) Enable the service from systemctl
systemctl enable jboss
systemctl daemon-reload

 

3) Test
systemctl start jboss
systemctl status jboss -l

systemctl stop jboss
systemctl status jboss -l

Systemctl for Weblogic in RHEL7

If you have existing start/stop scripts that can start/stop all admin and managed servers in one shot, below would be the configuration for systemctl:

1) Prepare file /etc/systemd/system/wls_myservice.service

[Unit]
Description=Weblogic Startup
After=network.target

[Service]
Type=forking
User=weblogic
Group=weblogic
TimeoutSec=300
ExecStart=/appl/myservice/bin/start.sh
ExecStop=/appl/myservice/bin/stop.sh
Restart=no

[Install]
WantedBy=multi-user.target

 

2) Enable the service from systemctl
systemctl enable wls_myservice
systemctl daemon-reload

 

3) Test
systemctl start wls_myservice
systemctl status wls_myservice -l

systemctl stop wls_myservice
systemctl status wls_myservice -l

Systemctl for Tomcat in RedHat Enterprise Linux 7

If tomcat requires parameters that have been set in .bash_profile, below are steps to configure systemctl:

1) Create files with below content (check ownership and permission)

#!/bin/sh
#/appl/myservice/scripts/start.sh

SERVICE=’myservice’
SERVICE_USER=’tc_myservice’

START_TOMCAT=”/opt/tomcat.${SERVICE}/bin/startup.sh”

if [ X”$USER” = X”$SERVICE_USER” ]; then
${START_TOMCAT}
else
su – ${SERVICE_USER} -c ${START_TOMCAT}
fi
#!/bin/sh
#/appl/myservice/scripts/stop.sh

SERVICE=’myservice’
SERVICE_USER=’tc_myservice’

STOP_TOMCAT=”/opt/tomcat.${SERVICE}/bin/shutdown.sh”

if [ X”$USER” = X”$SERVICE_USER” ]; then
${STOP_TOMCAT}
else
su – ${SERVICE_USER} -c ${STOP_TOMCAT}
fi

 

2) Create file /etc/systemd/system/tomcat.myservice.service

[Unit]
Description=Tomcat process for myservice
After=multi-user.target

[Service]
Type=forking
User=tc_myservice
Group=tc_myservice
ExecStartPre=/bin/bash –login -c ‘env > /tmp/.myservice-environment-file’
ExecStart=/appl/myservice/scripts/start.sh
ExecStop=/appl/myservice/scripts/stop.sh
EnvironmentFile=-/tmp/.myservice-environment-file
Restart=no

[Install]
WantedBy=multi-user.target

 

3) Enable the service from systemctl
systemctl enable tomcat.myservice
systemctl daemon-reload

 

4) Test
systemctl start tomcat.myservice
systemctl status tomcat.myservice -l

systemctl stop tomcat.myservice
systemctl status tomcat.myservice -l