mirror of
https://github.com/Kakune55/PyGetGPT.git
synced 2025-06-28 15:58:04 +08:00
Compare commits
No commits in common. "aab5043fed24049f81b19982edc2b3e049ec6c4a" and "c10d5d6ff8620c3df6fec541bbafc7fda38f0298" have entirely different histories.
aab5043fed
...
c10d5d6ff8
@ -1,79 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
VENV_DIR=".venv"
|
|
||||||
PYTHON_APP="main.py"
|
|
||||||
LOG_FILE="output.log"
|
|
||||||
PID_FILE="app.pid"
|
|
||||||
|
|
||||||
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"
|
|
||||||
nohup python3 "$PYTHON_APP" > "$LOG_FILE" 2>&1 &
|
|
||||||
echo $! > "$PID_FILE"
|
|
||||||
echo -e "\033[32m Application started! \033[0m"
|
|
||||||
}
|
|
||||||
|
|
||||||
stop_app() {
|
|
||||||
if [ ! -f "$PID_FILE" ]; then
|
|
||||||
echo -e "\033[31m PID file not found! \033[0m"
|
|
||||||
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"
|
|
||||||
else
|
|
||||||
echo -e "\033[31m Application not running or PID not found! \033[0m"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
check_app_status() {
|
|
||||||
if [ ! -f "$PID_FILE" ]; then
|
|
||||||
echo -e "\033[31m Application not running! \033[0m"
|
|
||||||
exit 1
|
|
||||||
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
|
|
||||||
start)
|
|
||||||
start_app
|
|
||||||
;;
|
|
||||||
stop)
|
|
||||||
stop_app
|
|
||||||
;;
|
|
||||||
status)
|
|
||||||
check_app_status
|
|
||||||
;;
|
|
||||||
restart)
|
|
||||||
restart_app
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo -e "\033[33m Usage: $0 {start|stop|status|restart} \033[0m"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
@ -1,6 +0,0 @@
|
|||||||
pymysql
|
|
||||||
requests
|
|
||||||
flask
|
|
||||||
zhipuai
|
|
||||||
openai
|
|
||||||
flask_cors
|
|
12
start.sh
Normal file
12
start.sh
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# 定义要运行的Python文件
|
||||||
|
PYTHON_APP="main.py"
|
||||||
|
|
||||||
|
# 使用nohup命令启动Python程序,并将其输出重定向到日志文件
|
||||||
|
nohup python3 $PYTHON_APP > output.log 2>&1 &
|
||||||
|
|
||||||
|
# 打印消息,通知用户程序已启动
|
||||||
|
echo "Python application started!"
|
||||||
|
|
||||||
|
# 可以添加任何其他需要的启动逻辑
|
18
stop.sh
Normal file
18
stop.sh
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# 定义要停止的Python文件
|
||||||
|
PYTHON_APP="main.py"
|
||||||
|
|
||||||
|
# 使用ps命令查找Python进程,并使用grep过滤出要停止的进程
|
||||||
|
PID=$(ps -ef | grep $PYTHON_APP | grep -v grep | awk '{print $2}')
|
||||||
|
|
||||||
|
# 检查是否找到了进程
|
||||||
|
if [ -z "$PID" ]; then
|
||||||
|
echo "Python application is not running!"
|
||||||
|
else
|
||||||
|
# 使用kill命令停止进程
|
||||||
|
kill $PID
|
||||||
|
echo "Python application stopped!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 可以添加任何其他需要的停止逻辑
|
Loading…
x
Reference in New Issue
Block a user