|  |  |  | 
|---|
|  |  |  | from email.mime.text import MIMEText | 
|---|
|  |  |  | from email.header import Header | 
|---|
|  |  |  | import datetime | 
|---|
|  |  |  | import subprocess | 
|---|
|  |  |  | # get: request.query.username request.GET.get('username','') | 
|---|
|  |  |  | # post: request.forms.get('username')  request.POST.get('username') | 
|---|
|  |  |  | #=============================================================================== | 
|---|
|  |  |  | 
|---|
|  |  |  | pResult = pResult.read() | 
|---|
|  |  |  | if "PID" in pResult or "pid" in pResult: | 
|---|
|  |  |  | return " =======服务器已经开启,请再次确认服务器情况, EventServer.exe运行中" | 
|---|
|  |  |  | os.system(r"call D:\ProjectServer\LaunchServerManager\正常开服.bat") | 
|---|
|  |  |  | #os.system(r"call D:\ProjectServer\LaunchServerManager\正常开服.bat") | 
|---|
|  |  |  | # system call会导致子进程占用父进程的文件描述符导致端口无法释放, 影响重启使用 | 
|---|
|  |  |  | # 如果需要保持子进程持续长期运行的应该调用 subprocess.Popen(cmd, close_fds=True) | 
|---|
|  |  |  | cmd = r"D:\ProjectServer\LaunchServerManager\正常开服.bat" | 
|---|
|  |  |  | subprocess.Popen(cmd, close_fds=True) | 
|---|
|  |  |  | return "open success" | 
|---|
|  |  |  | elif result == "close": | 
|---|
|  |  |  | # 记得关服后或者重启机器需自动启动服务器控制台 | 
|---|