#!/bin/bash
#
# description: SERVICE_NAME
DAEMON=/path/to/SERVICE_NAME/bin/SERVICE_NAME
case "$1" in
start)
$DAEMON start
;;
stop)
$DAEMON stop
;;
status)
$DAEMON status
;;
restart)
$DAEMON stop
sleep 1
$DAEMON start
;;
*)
echo "Usage: $0 {start|stop|status|restart}"
exit 1
;;
esac
exit 0
=================== Script Start/Stop Service =====================
#!/usr/bin/env bash
# PID File
SERVICENAME_PID_FILE=$(grep pid /path/to/servicename/etc/SERVICENAME/SERVICENAME.conf | awk '{print $2}')
case ${1} in
start)
echo "Starting SERVICENAME..."
nohup /path/to/servicename/libexec/SERVICENAME -h "host/service" -g SERVICENAME -u SERVICENAME -f /path/to/servicename/etc/SERVICENAME/SERVICENAME.conf
;;
debug)
echo "Starting SERVICENAME (debug)..."
/path/to/servicename/libexec/SERVICENAME -h "host/service" -g SERVICENAME -u SERVICENAME -f /path/to/servicename/etc/SERVICENAME/SERVICENAME.conf -d65537
;;
stop)
if [ -e ${SERVICENAME_PID_FILE} ] ; then
PID=$(cat ${SERVICENAME_PID_FILE})
echo -n "Stopping SERVICENAME (${PID}) "
kill ${PID}
i=0
while [ $i -lt 5 ] ; do
echo -n ". "
sleep 1
let i=$i+1
done
echo -e "\n"
else
echo "SERVICENAME is not running"
fi
;;
restart)
${0} stop && ${0} start
;;
*)
echo "Usage: ${0} start|stop|restart|debug"
;;
esac
exit 0
# ========================= End =============================#
Note: Copy this script to /etc/init.d if you want to use this command as /etc/init.d/servicename
user command : insserve servicename to copy these file into the start needed.
No comments:
Post a Comment