Skip to content

Commit

Permalink
🦊fix: 修复轮询任务无法拉起服务
Browse files Browse the repository at this point in the history
  • Loading branch information
Cassianvale committed Jan 28, 2024
1 parent 4b70d09 commit d2af66e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions task_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ def polling_task(self):
# 启动程序前检查, 如果存在服务端则不再进行启动操作,改为每次循环结尾关闭进程
result = subprocess.run(['tasklist', '/FI', 'IMAGENAME eq PalServer.exe'], capture_output=True, text=True)
if 'PalServer.exe' not in result.stdout:
INFO.logger.info("[ 前置检查 ] 未检测到 PalServer 服务,正在启动......")
print("[ 前置检查 ] 未检测到 PalServer 服务,正在启动......")
self.start_program()

INFO.logger.info(f'[ 轮询任务 ] 服务器将进入重启倒计时,设置时长为 {self.conf["restart_interval"]} 秒......')
Expand Down Expand Up @@ -112,12 +114,16 @@ def polling_task(self):

print(f'\r[ 轮询任务 ] 服务器将在 {i} 秒后重启......', end='')
time.sleep(1)

# 关闭服务端 放在循环的结尾,可以让用户不用关闭服务器的情况下启动本脚本
INFO.logger.info("[ 轮询任务 ] 正在关闭任何在运行的 PalServer 服务......")
print("\r\033[K", end='')
print("[ 轮询任务 ] 正在关闭任何在运行的 PalServer 服务......")
subprocess.run(['taskkill', '/f', '/im', self.appName], stderr=subprocess.DEVNULL)

# 重启程序
self.start_program()

def start_daemon(self):
# 守护进程代码
while True:
Expand Down

0 comments on commit d2af66e

Please sign in to comment.