service nginx start
cd /etc/rc.d/init.d
chmod +x codegen
chkconfig --add codegen
chkconfig codegen on
off: 关
#!/bin/sh
# chkconfig: 2345 55 25
JARPATH=/www/wwwroot/codegen.hntool.vip/
JARNAME=code-generator.jar
EXEC=`nohup /usr/java/jdk1.8.0_251/bin/java -Xmx256m -Xms256m -jar ${JARPATH}${JARNAME} >> ${JARPATH}log.out 2>&1 &`
PIDFILE=/www/wwwroot/codegen.hntool.vip/codegen.pid
codegen_start(){
if [ -f $PIDFILE ]; then
ps -p $(cat ${PIDFILE}) > /dev/null 2>&1
if [ $? -ne "0" ]; then
rm -f ${PIDFILE}
else
echo "codegen is running! ($(cat ${PIDFILE}))"
exit 0
fi
fi
echo "Starting codegen server..."
$EXEC
echo $!> ${PIDFILE}
echo "Starting codegen success!"
}
codegen_status(){
if [ -f $PIDFILE ]; then
ps -p $(cat ${PIDFILE}) > /dev/null 2>&1
if [ $? -ne "0" ]; then
echo "codegen is not running, buy pid file is exits ${PIDFILE}"
exit 1
else
echo "codegen is running! ($(cat ${PIDFILE}))"
exit 0
fi
else
echo "codegen is stopped"
exit 0
fi
}
codegen_stop(){
echo "Stopping ..."
sleep 1
if [ -f $PIDFILE ];then
kill -9 `ps -ef|grep $JARNAME|grep -v grep|grep -v stop|awk '{print $2}'`
fi
rm -f ${PIDFILE}
echo "codegen stopped"
}
case "$1" in
start)
codegen_start
;;
stop)
codegen_stop
;;
status)
codegen_status
;;
restart|reload)
codegen_stop
sleep 0.3
codegen_start
;;
*)
echo "Please use start or stop as first argument"
;;
esac