import os
import time


def check():
    out = os.popen("ps aux | grep diaryQueueUpdate.py").read()
    flag = 1
    for line in out.splitlines():
        if 'python diaryQueueUpdate.py' in line:
            flag = 2
    return flag


if __name__ == "__main__":
    #TODO 正式上线后，把下面的循环和time.sleep打开
    # while True:
    if check() == 1:
        os.popen('python diaryQueueUpdate.py')
        print("成功重启diaryQueueUpdate")
    # time.sleep(300)