Creating a XPLG service with init.d (Ubuntu / CentOS / RHEL / AWS Linux AMI)
Another tool to create a service to XPLG beside systemctl is the init.d utility.
Init.d is more common and old feature on linux servers, and it enables configuring the service with control about its status after a restart of the machine or after the automatic recycle mechanism of XPLG.
RHEL / AWS Linux AMI
In order to configure such a service, you have to perform the following steps:
With user root, create a file with the name 'XPLG' under /etc/init.d.
Edit the file and add set its contents to:
#!/bin/bash
# chkconfig: 2345 20 80
# description: XPLG Center init script
# Source function library.
. /etc/init.d/functions
start() {
cd [XPLG_INSTALLATION_DIR]
sudo sh runXpoLog.sh start
}
stop() {
cd [XPLG_INSTALLATION_DIR]
sudo sh runXpoLog.sh stop
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
cd [XPLG_INSTALLATION_DIR]
sudo sh runXpoLog.sh stat
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
esac
exit 0
Grant an execution permission on the file with the command: chmod +x /etc/init.d/XPLG
4. Ensure that the service is recognized by the chkconfig utility with the command: chkconfig --add XPLG
The command by which you can control the service is: service XPLG start/stop/restart/status.
In order to verify that the service was configured properly, you can run all this commands and ensure that each one of them performs as expected.
Example to a XPLG service file:
Ubuntu / CentOS
With user root, create a file with the name 'XPLG' under /etc/init.d.
Edit the file contents to:
#! /bin/sh
### BEGIN INIT INFO
# Provides: XPLG
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: XPLG
# Description: This file starts and stops XPLG server
#
### END INIT INFO
case "$1" in
start)
cd /opt/XPLGCenter/
sh runXpoLog.sh start
;;
stop)
cd /opt/XPLGCenter/
sh runXpoLog.sh stop
;;
restart)
cd /opt/XPLGCenter/
sh runXpoLog.sh stop
sh runXpoLog.sh start
;;
status)
cd /opt/XPLGCenter/
sh runXpoLog.sh stat
;;
*)
echo "Usage: XPLG {start|stop|restart|status}" >&2
exit 3
;;
esac
3. Grant an execution permission on the file with the command: chmod +x /etc/init.d/XPLG
4. Ensure that the service is recognized by the chkconfig mechanism with the command: chkconfig --add XPLG
Note: In order to verify that the service was configured properly, you can run all this commands and ensure that each one of them performs as expected.