feat:更新启动脚本 防止误杀进程
This commit is contained in:
parent
398f729991
commit
eff85c91db
@ -2,31 +2,61 @@
|
|||||||
|
|
||||||
VENV_DIR=".venv"
|
VENV_DIR=".venv"
|
||||||
PYTHON_APP="main.py"
|
PYTHON_APP="main.py"
|
||||||
|
LOG_FILE="output.log"
|
||||||
|
PID_FILE="app.pid"
|
||||||
|
|
||||||
start_app() {
|
start_app() {
|
||||||
|
if [ ! -d "$VENV_DIR" ]; then
|
||||||
|
echo -e "\033[31m Virtual environment directory $VENV_DIR not found! \033[0m"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "$PYTHON_APP" ]; then
|
||||||
|
echo -e "\033[31m Python application $PYTHON_APP not found! \033[0m"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
source "$VENV_DIR/bin/activate"
|
source "$VENV_DIR/bin/activate"
|
||||||
nohup python3 $PYTHON_APP > output.log 2>&1 &
|
nohup python3 "$PYTHON_APP" > "$LOG_FILE" 2>&1 &
|
||||||
|
echo $! > "$PID_FILE"
|
||||||
echo -e "\033[32m Application started! \033[0m"
|
echo -e "\033[32m Application started! \033[0m"
|
||||||
}
|
}
|
||||||
|
|
||||||
stop_app() {
|
stop_app() {
|
||||||
pid=$(ps aux | grep $PYTHON_APP | grep -v grep | awk '{print $2}')
|
if [ ! -f "$PID_FILE" ]; then
|
||||||
if [ -n "$pid" ]; then
|
echo -e "\033[31m PID file not found! \033[0m"
|
||||||
kill $pid
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
pid=$(cat "$PID_FILE")
|
||||||
|
if [ -n "$pid" ] && kill -0 "$pid" 2>/dev/null; then
|
||||||
|
kill "$pid"
|
||||||
|
rm "$PID_FILE"
|
||||||
echo -e "\033[32m Application ended! \033[0m"
|
echo -e "\033[32m Application ended! \033[0m"
|
||||||
else
|
else
|
||||||
echo -e "\033[31m Application not runing! \033[0m"
|
echo -e "\033[31m Application not running or PID not found! \033[0m"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
check_app_status() {
|
check_app_status() {
|
||||||
pid=$(ps aux | grep $PYTHON_APP | grep -v grep | awk '{print $2}')
|
if [ ! -f "$PID_FILE" ]; then
|
||||||
if [ -n "$pid" ]; then
|
echo -e "\033[31m Application not running! \033[0m"
|
||||||
echo -e "PID:" $pid
|
exit 1
|
||||||
echo -e "\033[32m Application runing! \033[0m"
|
|
||||||
else
|
|
||||||
echo -e "\033[31m Application not runing! \033[0m"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
pid=$(cat "$PID_FILE")
|
||||||
|
if [ -n "$pid" ] && kill -0 "$pid" 2>/dev/null; then
|
||||||
|
echo -e "PID: $pid"
|
||||||
|
echo -e "\033[32m Application running! \033[0m"
|
||||||
|
else
|
||||||
|
echo -e "\033[31m Application not running! \033[0m"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
restart_app() {
|
||||||
|
stop_app
|
||||||
|
start_app
|
||||||
|
echo -e "\033[32m Application restarted! \033[0m"
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@ -39,8 +69,11 @@ case "$1" in
|
|||||||
status)
|
status)
|
||||||
check_app_status
|
check_app_status
|
||||||
;;
|
;;
|
||||||
|
restart)
|
||||||
|
restart_app
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo -e "\033[33m Usage: $0 {start|stop|status}\033[0m"
|
echo -e "\033[33m Usage: $0 {start|stop|status|restart} \033[0m"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -13,39 +13,39 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1>诈骗信息</h1>
|
<h1>诈骗信息</h1>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>UUID</th>
|
<th>UUID</th>
|
||||||
<th>受害人号码</th>
|
<th>受害人号码</th>
|
||||||
<th>诈骗方式</th>
|
<th>诈骗方式</th>
|
||||||
<th>诈骗类型</th>
|
<th>诈骗类型</th>
|
||||||
<th>预警时间</th>
|
<th>预警时间</th>
|
||||||
<th>预警等级</th>
|
<th>预警等级</th>
|
||||||
<th>APP/URL名称</th>
|
<th>APP/URL名称</th>
|
||||||
<th>诈骗电话</th>
|
<th>诈骗电话</th>
|
||||||
<th>通话时长</th>
|
<th>通话时长</th>
|
||||||
<th>诈骗人账号</th>
|
<th>诈骗人账号</th>
|
||||||
<th>转账金额</th>
|
<th>转账金额</th>
|
||||||
<th>机构授权码</th>
|
<th>机构授权码</th>
|
||||||
<th>学号</th>
|
<th>学号</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for item in data %}
|
{% for item in data %}
|
||||||
<tr class="odd gradeX">
|
<tr class="odd gradeX">
|
||||||
{% for v in item %}
|
{% for v in item %}
|
||||||
{% if v == None %}
|
{% if v == None %}
|
||||||
<td>-</td>
|
<td>-</td>
|
||||||
{% else %}
|
{% else %}
|
||||||
<td>{{v}}</td>
|
<td>{{v}}</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
Loading…
x
Reference in New Issue
Block a user