zoukankan      html  css  js  c++  java
  • 通过web端启动关闭服务器程序以及检测程序运行状态

    #web端检测服务器程序运行,启动服务器程序,关闭服务器程序
    import os import sys import time import win32com.client def check_exsit(process_name): WMI = win32com.client.GetObject('winmgmts:') processCodeCov = WMI.ExecQuery('select * from Win32_Process where Name like "%{}%"'.format(process_name)) if len(processCodeCov) > 0: return True else: return False def game_status(): examples = ["RSConsole.exe", "CSConsole.exe", "GSConsole.exe"] for example in examples : res = check_exsit(example) if not res : return False return True def game_stop(): examples = ["RSConsole.exe", "GSConsole.exe", "CSConsole.exe"] for example in examples : res = check_exsit(example) if res : os.system('taskkill /f /im ' + example) time.sleep( 1 ) return True def game_start(): examples = ["CSConsole.exe", "GSConsole.exe", "RSConsole.exe"] examples_path = {"CSConsole.exe" : "F:/Server_RC_ATT/WYYGame/Bin/x64/Debug", "GSConsole.exe" : "F:/Server_RC_ATT/WYYGame/Bin/x64/Debug/GSATT2", "RSConsole.exe" : "F:/Server_RC_ATT/WYYGame/Bin/x64/Debug"} for example in examples : cmd_line = 'start "' + example + '" /d "' + examples_path[example] + '" /MIN "' + example + '"' #需要注意在进程名字,路径加双引号 os.system(cmd_line) time.sleep( 5 ) return True if __name__ == '__main__': operationType = sys.argv[1] if "game_status" == operationType : print(game_status()) if "game_stop" == operationType : print(game_stop()) if "game_start" == operationType : game_stop() print(game_start())

      

    php端調用

    <?php 
    	$a = "game_start";
    	exec("python F:/Server_RC_ATT/WYYGame/Bin/x64/game_status.py $a", $out, $res);
    	for($i = 0; $i < count($out); $i++) {
    		echo $out[$i];
    		echo "<br>";
    	}
    	echo $res;
    ?>
    

      

  • 相关阅读:
    Tomcat
    二叉树
    CDOJ 1962 天才钱vs学霸周2【最大流】
    次小生成树(POJ1679/CDOJ1959)
    CDOJ1927 爱吃瓜的伊卡洛斯(2) 【并查集】启发式合并+set
    HDU 1074 Doing Homework(DP状态压缩)
    uva 11367 (Dijkstra+DP)
    线段树模板
    openpose pytorch代码分析
    opencv图片坐标和数组下标
  • 原文地址:https://www.cnblogs.com/hailong88/p/13398849.html
Copyright © 2011-2022 走看看