refactor(scripts): 重构主程序执行逻辑

- 修改 docker-entrypoint.sh,增加睡眠时间以减少资源占用
- 重命名 main.py 中的函数 run_task 为 run
- 更新 scripts.py,使用 while 循环持续查询订单
This commit is contained in:
danial
2024-12-31 00:27:47 +08:00
parent 8a5bc72cb3
commit 9d63f6068c
3 changed files with 17 additions and 14 deletions

View File

@@ -11,5 +11,5 @@ while true; do
# 如果成功获取锁,则运行 Python 脚本
python -u main.py
) 200>$LOCKFILE
sleep 1
sleep 5
done

View File

@@ -1,4 +1,4 @@
from src.cmd.scripts import run_task
from src.cmd.scripts import run
if __name__ == "__main__":
run_task()
run()

View File

@@ -181,6 +181,8 @@ def run_task():
"""
# 注册信号处理程序
has_been_console = False
master_node_service = MasterNodeService()
while True:
master_node_service = MasterNodeService()
# 1s获取两次订单
master_order = master_node_service.query_order()
@@ -193,6 +195,7 @@ def run_task():
print(f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\t暂时没有订单")
if datetime.now().second % 10 != 0 and has_been_console:
has_been_console = False
# time.sleep(1)
def run():
# signal.signal(signal.SIGINT, signal_handler)