使用systemctl添加自启动脚本支持,服务名为kangda_websocket, kangda_sync_robot
This commit is contained in:
parent
0c8b6add64
commit
5031e01695
12
kangda_sync_robot.service
Normal file
12
kangda_sync_robot.service
Normal file
@ -0,0 +1,12 @@
|
||||
[Unit]
|
||||
Description=My Custom Startup Script
|
||||
|
||||
[Service]
|
||||
User=admin-root
|
||||
# 这里确保自己对 这个脚本有执行权限。
|
||||
ExecStart=/home/admin-root/haotian/康达瑞贝斯/康达后台项目/start_sync_robot.sh
|
||||
Restart=on-failure
|
||||
WorkingDirectory=/home/admin-root/
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
12
kangda_websocket.service
Normal file
12
kangda_websocket.service
Normal file
@ -0,0 +1,12 @@
|
||||
[Unit]
|
||||
Description=My Custom Startup Script
|
||||
|
||||
[Service]
|
||||
User=admin-root
|
||||
# 这里确保自己对 这个脚本有执行权限。
|
||||
ExecStart=/home/admin-root/haotian/康达瑞贝斯/康达后台项目/start_websocket.sh
|
||||
Restart=on-failure
|
||||
WorkingDirectory=/home/admin-root/
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
0
run_sync_robot.py
Normal file → Executable file
0
run_sync_robot.py
Normal file → Executable file
21
start_sync_robot.sh
Normal file → Executable file
21
start_sync_robot.sh
Normal file → Executable file
@ -1,5 +1,23 @@
|
||||
#! /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/robot"
|
||||
|
||||
mkdir -p $LOG_DIR
|
||||
@ -14,7 +32,8 @@ if pgrep -f "run_sync_robot.py" > /dev/null; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
nohup python run_sync_robot.py > "$LOG_FILE" 2>&1 &
|
||||
# nohup python run_sync_robot.py > "$LOG_FILE" 2>&1 &
|
||||
nohup python run_sync_robot.py > "$LOG_FILE" 2>&1
|
||||
|
||||
# 保存进程id
|
||||
echo $! > "$LOG_DIR/robot.pid"
|
||||
|
||||
22
start_websocket.sh
Normal file → Executable file
22
start_websocket.sh
Normal file → Executable file
@ -1,5 +1,22 @@
|
||||
#!/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
|
||||
@ -14,7 +31,10 @@ if pgrep -f "run_websocket.py" > /dev/null; then
|
||||
fi
|
||||
|
||||
# 在后台运行程序并将输出重定向到日志文件
|
||||
nohup python run_websocket.py > "$LOG_FILE" 2>&1 &
|
||||
# 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"
|
||||
|
||||
30
测试Ocr.py
Normal file
30
测试Ocr.py
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
import os
|
||||
from app.util.baiduOcr import BadiduOcr
|
||||
from app.util.kangda import Kangda
|
||||
|
||||
|
||||
|
||||
baiduOcr = BadiduOcr()
|
||||
kangda = Kangda()
|
||||
|
||||
file_path = '/home/admin-root/haotian/康达瑞贝斯/康达后台项目/imagesOcr'
|
||||
|
||||
image_path = [os.path.join(file_path, t) for t in os.listdir(file_path)]
|
||||
|
||||
for image in image_path:
|
||||
result = baiduOcr.image_inference(image)
|
||||
value, conf = baiduOcr.parse_result(result)
|
||||
print("-"*100)
|
||||
print("image: ", image)
|
||||
print("value:", value)
|
||||
print("conf:", conf)
|
||||
status = None
|
||||
if len(value) > 0 and len(value) < 3:
|
||||
status = kangda.parse_value(value)
|
||||
print("status:", status, status.value if status else 0)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user