代码拉取完成,页面将自动刷新
#!/bin/bash
#启用虚拟环境
_SERVER_NAME="manage_daemon"
PID_NAME=$_SERVER_NAME".pid"
#PID存放
_RUNPID=/tmp/$PID_NAME
start()
{
if [ ! -z "$_RUNPID" ]; then
if [ -f "$_RUNPID" ]; then
if [ -s "$_RUNPID" ]; then
echo "Existing PID file found during start."
if [ -r "$_RUNPID" ]; then
PID=`cat "$_RUNPID"`
ps -p $PID >/dev/null 2>&1
if [ $? -eq 0 ] ; then
echo "$_SERVER_NAME appears to still be running with PID $PID. Start aborted."
echo "If the following process is not a Tomcat process, remove the PID file[$_RUNPID] and try again:"
ps -f -p $PID
exit 1
else
echo "Removing/clearing stale PID file."
rm -f "$_RUNPID" >/dev/null 2>&1
if [ $? != 0 ]; then
if [ -w "$_RUNPID" ]; then
cat /dev/null > "$_RUNPID"
else
echo "Unable to remove or clear stale PID file. Start aborted."
exit 1
fi
fi
fi
else
echo "Unable to read PID file. Start aborted."
exit 1
fi
else
rm -f "$_RUNPID" >/dev/null 2>&1
if [ $? != 0 ]; then
if [ ! -w "$_RUNPID" ]; then
echo "Unable to remove or write to empty PID file. Start aborted."
exit 1
fi
fi
fi
fi
fi
_CONSOLE_LOG=/tmp/manage_daemon_`date +%Y-%m-%d`.log
nohup pipenv run python3 manage.py runserver 0.0.0.0:28555 >> $_CONSOLE_LOG 2>&1 & echo $! > $_RUNPID
echo "start end,you can command..."
echo " tail -f $_CONSOLE_LOG"
tail -f $_CONSOLE_LOG
}
stop()
{
shift
SLEEP=5
if [ ! -z "$_RUNPID" ]; then
if [ -f "$_RUNPID" ]; then
if [ -s "$_RUNPID" ]; then
kill -0 `cat "$_RUNPID"` >/dev/null 2>&1
if [ $? -gt 0 ]; then
echo "PID file found but either no matching process was found or the current user does not have permission to stop the process. Stop aborted."
exit 1
fi
else
echo "PID file is empty and has been ignored."
fi
else
echo "$_RUNPID was set but the specified file does not exist. Is $_SERVER_NAME running? Stop aborted."
exit 1
fi
fi
echo "asus....."
# stop failed. Shutdown port disabled? Try a normal kill.
if [ ! -z "$_RUNPID" ]; then
echo "The stop command failed. Attempting to signal the process to stop through OS signal."
kill -15 `cat "$_RUNPID"` >/dev/null 2>&1
rm -f "$_RUNPID" >/dev/null 2>&1
fi
echo "stop end"
}
debug()
{
pipenv run python3 manage.py runserver 0.0.0.0:28555
}
if [ "$1" = "start" ] ; then
start
elif [ "$1" = "debug" ] ; then
debug
elif [ "$1" = "stop" ]; then
stop
elif [ "$1" = "restart" ]; then
stop
start
elif [ "$1" = "-h" ]; then
# $0 是脚本名称
echo "Usage: $0 ( commands ... )"
echo "commands:"
echo " start 启动服务"
echo " stop 停止服务"
exit 1
else
debug
fi
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。