1 Star 0 Fork 10

ih0cker/python-websocket-shell

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
start.sh 1.30 KB
一键复制 编辑 原始数据 按行查看 历史
#!/bin/bash
#WORKDIR=$(dirname `readlink -f $0`)
WORKDIR=$(cd "$(dirname "$0")"; pwd)
cd $WORKDIR
appname="server";
function stop()
{
pid=$(ps aux | grep $WORKDIR | grep $appname | grep -v grep | awk '{print $2}')
if [ -n "$pid" ] ; then
kill -9 $pid
echo "kill server $pid"
fi
pid=$(ps aux | grep $WORKDIR | grep $appname | grep -v grep | awk '{print $2}')
while [ -n "$pid" ]
do
sleep 1
pid=$(ps aux | grep $WORKDIR | grep $appname | grep -v grep | awk '{print $2}')
echo "$WORKDIR/$appname.py still alive "
done
echo "$WORKDIR/$appname.py had been killed"
}
function start()
{
#首先看下进程是否存在,如果存在不再次启动而是提示先关闭
pid=$(ps aux | grep $WORKDIR | grep $appname | grep -v grep | awk '{print $2}')
if [ -n "$pid" ] ; then
echo "$WORKDIR/$appname.py still alive please kill it first!!!"
return 1;
fi
#切换到脚本所在目录
cd $WORKDIR
rm debug.log
nohup python -u $WORKDIR/$appname.py > ./debug.log 2>&1 &
echo "server is start"
}
chmod 777 web/config.json
chmod 777 web/webdisk.log
case "$1" in
start)
start;;
restart)
stop;
start;;
stop)
stop ;;
help)
echo "start|restart|stop";;
*)
stop;
start ;;
esac
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ih0cker/python-websocket-shell.git
git@gitee.com:ih0cker/python-websocket-shell.git
ih0cker
python-websocket-shell
python-websocket-shell
master

搜索帮助