kangda/start_websocket.sh

43 lines
1.1 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
__conda_setup="$('/home/admin-root/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/home/admin-root/miniconda3/etc/profile.d/conda.sh" ]; then
. "/home/admin-root/miniconda3/etc/profile.d/conda.sh"
else
export PATH="/home/pro/miniconda3/bin:$PATH"
fi
fi
unset __conda_setup
conda activate ocr
cd /home/admin-root/haotian/康达瑞贝斯/康达后台项目
# 创建日志目录
LOG_DIR="logs/websocket"
mkdir -p $LOG_DIR
# 生成日志文件名(使用当前时间)
LOG_FILE="$LOG_DIR/websocket_$(date +%Y%m%d_%H%M%S).log"
# 检查是否已经在运行
if pgrep -f "run_websocket.py" > /dev/null; then
echo "WebSocket客户端已经在运行中"
exit 1
fi
# 在后台运行程序并将输出重定向到日志文件
# nohup python run_websocket.py > "$LOG_FILE" 2>&1 &
# 使用systemctl控制运行
nohup python run_websocket.py > "$LOG_FILE" 2>&1
# 保存进程ID
echo $! > "$LOG_DIR/websocket.pid"
echo "WebSocket客户端已启动日志保存在: $LOG_FILE"
echo "进程ID: $(cat $LOG_DIR/websocket.pid)"