From 94f44d3300bceeb9e1c99a19735cfbb1e180ad61 Mon Sep 17 00:00:00 2001 From: xyj <10908227994@qq.com> Date: Fri, 1 Dec 2023 13:51:47 +0800 Subject: [PATCH] test --- MQTT.py | 10 +++++----- conf/mqtt.conf | 4 ++-- conf/test.conf | 13 +++++++++++++ conf/test2.conf | 10 ++++++++++ conf/push_stream.conf => push_stream.conf | 2 +- reload_conf.sh | 5 ++--- start_push.sh | 4 +++- stop_push.sh | 4 +++- update.sh | 10 +++++++--- 9 files changed, 46 insertions(+), 16 deletions(-) create mode 100755 conf/test.conf create mode 100755 conf/test2.conf rename conf/push_stream.conf => push_stream.conf (86%) diff --git a/MQTT.py b/MQTT.py index 55a29ed..899ab03 100644 --- a/MQTT.py +++ b/MQTT.py @@ -18,16 +18,16 @@ def on_connect(client, userdata, flags, rc): def on_message(client, userdata, msg): data = json.loads(msg.payload.decode('utf-8'))["msg"] if data == "push_stream": - # TODO 启动推流视频 + # 启动推流视频 push_stream() elif data == "close_stream": - # TODO 关闭推流视频 + # 关闭推流视频 close_stream() elif data == "exec": - # TODO 执行命令 更新配置 + # 执行命令 exec_sh() elif data == "update": - # TODO git更新项目 + # git更新项目和配置文件 update() else: client.publish('conn_error', payload='No Such Type', qos=0) @@ -40,6 +40,6 @@ if __name__ == '__main__': client.on_connect = on_connect client.on_message = on_message # Establish a connection - client.connect('ceshi-mqtt.lihaink.cn', 1883) + client.connect('127.0.0.1', 1883) # Publish a message client.loop_forever() diff --git a/conf/mqtt.conf b/conf/mqtt.conf index e992409..dad5e0f 100644 --- a/conf/mqtt.conf +++ b/conf/mqtt.conf @@ -1,6 +1,6 @@ [program:mqtt] -directory=/home/lihai/PycharmProjects/pythonProject/lot_manager -command=/home/lihai/anaconda3/envs/chatchat/bin/python MQTT.py +directory=/home/lihai//PycharmProjects/pythonProject/lot_manager +command=/home/lihai//anaconda3/envs/chatchat/bin/python MQTT.py user=lihai autostart=true autorestart=true diff --git a/conf/test.conf b/conf/test.conf new file mode 100755 index 0000000..e4083a2 --- /dev/null +++ b/conf/test.conf @@ -0,0 +1,13 @@ +[program:test] +directory=/home/lihai/PycharmProjects/pythonProject/lot_manager +command=/home/lihai/anaconda3/envs/chatchat/bin/python test.py +user=lihai +;是否随开机自启 或者reload自启动 +autostart=false +;失败重启 +autorestart=true +;重启次数 +restart_times=3 +redirect_stderr=true +stopsignal=TERM +stopasgroup=True diff --git a/conf/test2.conf b/conf/test2.conf new file mode 100755 index 0000000..3dccdbc --- /dev/null +++ b/conf/test2.conf @@ -0,0 +1,10 @@ +[program:test2] +directory=/home/lihai/PycharmProjects/pythonProject/lot_manager +command=/home/lihai/anaconda3/envs/chatchat/bin/python test.py +user=lihai +autostart=false +autorestart=true +restart_times=3 +redirect_stderr=true +stopsignal=TERM +stopasgroup=True diff --git a/conf/push_stream.conf b/push_stream.conf similarity index 86% rename from conf/push_stream.conf rename to push_stream.conf index f2311da..2ac1028 100644 --- a/conf/push_stream.conf +++ b/push_stream.conf @@ -1,6 +1,6 @@ [program:push_stream] directory=/home/lihai/PycharmProjects/pythonProject/lot_manager -command=/usr/bin/ffmpeg -rtsp_transport tcp -re -i rtsp://admin:123456@192.168.0.123:554/mpeg4 -c:v copy -c:a aac -preset ultrafast -r 20 -flvflags no_duration_filesize -f rtsp -rtsp_transport tcp rstp://47.108.186.87:554/live/test9 +command=/usr/bin/ffmpeg -rtsp_transport tcp -re -i rtsp://admin:123456@192.168.0.123:554/mpeg4 -c:v copy -c:a aac -preset ultrafast -r 20 -flvflags no_duration_filesize -f rtsp -rtsp_transport tcp rstp://127.0.0.1:554/live/test user=lihai autostart=true autorestart=true diff --git a/reload_conf.sh b/reload_conf.sh index f59097e..446b678 100644 --- a/reload_conf.sh +++ b/reload_conf.sh @@ -1,7 +1,6 @@ #!/bin/bash #复制配置文件 -cp -r conf/*.conf /etc/supervisor/conf.d/ +set -e +cp -r reload_conf/*.conf /etc/supervisor/conf.d/ # 重启所有配置 supervisorctl reload -# 推流不启动 -supervisorctl stop push_stream diff --git a/start_push.sh b/start_push.sh index ed60632..d536bca 100644 --- a/start_push.sh +++ b/start_push.sh @@ -1,2 +1,4 @@ #!/bin/bash -supervisorctl start push_stream \ No newline at end of file +set -e + +supervisorctl start push_stream diff --git a/stop_push.sh b/stop_push.sh index fc96a8f..3ddb7f6 100644 --- a/stop_push.sh +++ b/stop_push.sh @@ -1,2 +1,4 @@ #!/bin/bash -supervisorctl stop push_stream \ No newline at end of file +set -e + +supervisorctl stop test diff --git a/update.sh b/update.sh index 35b0308..5da19c2 100644 --- a/update.sh +++ b/update.sh @@ -1,4 +1,8 @@ #!/bin/bash - -# TODO git更新 -git pull \ No newline at end of file +set -e +# git更新 +git pull origin master +# 配置文件复制到supervisor管理 +cp -r conf/*.conf /etc/supervisor/conf.d/ +# 更新配置文件 +supervisorctl reread