コード例 #1
0
def check_process_exit():
    for i in process_string:
        if os.path.exists(parent_path + "/pids/" + i + "_pid"):
            os.chdir(parent_path + "/pids/")
            read_pid = utils.read_file(i + "_pid")
            pid = utils.process_pid(read_pid)
            for j in pid:
                if j == read_pid:
                    print "进程存在"
                    os._exit(1)
コード例 #2
0
ファイル: stop_listen.py プロジェクト: lineCode/game_server-1
def start():
    for ps in process_string:
        os.chdir(child_path + "/script_file")
        listen_pid = "listen_" + ps + "_pid"
        if os.path.exists(listen_pid):
            read_pid = utils.read_file(listen_pid)
            pid = utils.process_pid(read_pid)
            count = 1
            while True:
                if (try_stop_process(pid, read_pid, listen_pid)):
                    if count > 30:
                        print "kill 监听进程失败"
                        os._exit(1)
                    count = count + 1
                else:
                    break
コード例 #3
0
def stop_process():
    if os.path.exists(parent_path + "/pids"):
        os.chdir(parent_path + "/pids")
        if os.path.exists("gmd_pid"):
            read_pid = utils.read_file("gmd_pid")
            pid = utils.process_pid(read_pid)
            count = 1
            while True:
                if (try_stop_process(pid, read_pid)):
                    if count > 30:
                        os.system("kill -9 " + read_pid)
                        print "强制停止jxwy_gmd进程"
                        os._exit(1)
                    count = count + 1
                else:
                    break
コード例 #4
0
ファイル: stop_listen.py プロジェクト: lineCode/game_server-1
def try_stop_process(pid, read_pid, listen_pid):
    for p in pid:
        if p == read_pid:
            os.system("kill -9 " + read_pid)

    time.sleep(1)
    pid = utils.process_pid(read_pid)
    if isinstance(pid, list) and len(pid) == 0:
        os.system("rm " + listen_pid)
        return False
    for p in pid:
        if p == read_pid:
            return True
        else:
            os.system("rm " + listen_pid)
            return False
コード例 #5
0
def try_stop_process(pid, read_pid):
    for p in pid:
        if p == read_pid:
            if sign == 1:
                os.system("kill -9 " + read_pid)
            else:
                os.system("kill " + read_pid)

    time.sleep(1)
    pid = utils.process_pid(read_pid)
    if isinstance(pid, list) and len(pid) == 0:
        os.system("rm common_resourced_pid")
        return False
    for p in pid:
        if p == read_pid:
            return True
        else:
            os.system("rm common_resourced_pid")
            return False