作者:有点难 | 来源:互联网 | 2023-10-12 14:05
#!binsh#Author:Aaron.etcinit.dfunctionsexportPATHusrlocalsbin:usrlocalbin:sbin:bin:usrsbin
#!/bin/sh
#Author:Aaron
. /etc/init.d/functions
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/node/bin
base_dir=$(dirname $0)
start() {
echo "Start cloud......"
ps -ef | grep manage.py | grep 9999
status=`echo $?`
if [ $status -eq 0 ];then
echo "hcloud is running........"
else
daemon python $base_dir/manage.py runserver 0.0.0.0:9999 &>> /tmp/hcloud.log 2>&1 &
sleep 3
ps -ef | grep manage.py | grep 9999
start_status=`echo $?`
if [ $start_status -eq 0 ];then
echo "hcloud start sucess......."
else
echo "hcloud start fail......."
fi
fi
}
stop() {
echo "Stop hcloud......"
ps aux | grep -E 'manage.py' | grep 9999 |grep -v grep | awk '{print $2}' | xargs kill -9 &> /dev/null
ret=$?
if [ $ret -eq 0 ]; then
echo_success
echo
else
echo_failure
echo
fi
}
restart(){
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 2
esac