1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/xupingmao-xnote

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
sentinel.py 815
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
xupingmao Отправлено 20.04.2024 18:28 8a2831d
# encoding=utf-8
"""哨兵进程
错误码说明
错误码 | 说明
------| -------
0 | 正常退出
1 | 异常退出,一般是程序错误
https://blog.csdn.net/halfclear/article/details/72783900
"""
import sys
import os
import time
def get_current_time(format='%Y-%m-%d %H:%M:%S'):
return time.strftime(format)
def print_log(*args):
print(get_current_time(), *args)
def main():
args = sys.argv[1:]
args.insert(0, sys.executable)
cmd = " ".join(args)
print_log("command:", cmd)
while True:
# exit_code = subprocess.call(args, shell = True)
exit_code = os.system(cmd)
print_log("exit_code:", exit_code)
# Mac返回 52480
if exit_code in (205, 52480):
print_log("restart ...")
print_log("-" * 50)
print_log("-" * 50)
else:
return
if __name__ == '__main__':
main()

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/xupingmao-xnote.git
git@api.gitlife.ru:oschina-mirror/xupingmao-xnote.git
oschina-mirror
xupingmao-xnote
xupingmao-xnote
master