Esempio n. 1
0
def start_allservers():
    for server in serverList.split(","):
        if server in servers:
            server_port = int(servers[server])
            server_status = KillProc(ipAddr, server_port).port_check()
            if server_status is True:
                print "%s 服务器已在运行..." % server
            else:
                while KillProc(ipAddr, server_port).port_check() is not True:
                    optServer(server, "START")
Esempio n. 2
0
def startService():
    for service in serviceList.split(','):
        host = ipAddr
        port = int(eval(service + 'Port'))  # 端口必须为数字
        service_status = KillProc(host, port).port_check()
        cmd = eval(service + 'CMD')
        if service_status:
            print u"在%s服务器上服务端口为 %d 的 %s 服务已在运行......" % (host, port, service)
        else:
            subprocess.Popen(cmd, shell=True, stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE).wait()
            time.sleep(3)
            opt_status = KillProc(host, port).port_check()
            if opt_status:
                print u"在%s服务器上服务端口为 %d 的 %s 服务启动成功!" % (host, port, service)
            else:
                print u"在%s服务器上服务端口为 %d 的 %s 服务启动失败! " % (host, port, service)
Esempio n. 3
0
def optBasicService(host, port, name, opt, cmd):
    status = KillProc(host, port).port_check()
    if status:
        print u"在%s服务器上服务端口为 %d 的 %s 服务已在运行......" % (host, port, name)
    elif status != True and opt == "START":
        # (status, output) = commands.getstatusoutput(cmd)
        p = subprocess.Popen(cmd,
                             shell=False,
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE)
        time.sleep(1)
        status = KillProc(host, port).port_check()
        if status == 0:
            print u"在%s服务器上服务端口为 %d 的 %s 服务启动成功!" % (host, port, name)
        else:
            print u"在%s服务器上服务端口为 %d 的 %s 服务启动失败! 可能原因:%s" % (host, port, name,
                                                             output)
Esempio n. 4
0
def stop_allservers():
    for server in serverList.split(","):
        server_port = int(servers[server])
        server_status = KillProc(ipAddr, server_port).port_check()
        if server_status:
            optServer(server, "STOP")
        else:
            print "%s 服务器已关闭!" % server
Esempio n. 5
0
def state_allservers():
    print "%-14s :%-4s" % ("服务器名称", "状态")
    for (server_name, server_port) in servers.items():
        server_status = KillProc(ipAddr, int(server_port)).port_check()
        if server_status:
            print "%-14s :%s" % (server_name, "RUNNING")
        else:
            print "%-14s :%s" % (server_name, "SHUTDOWN")
Esempio n. 6
0
def envCheck():
    for service in serviceList.split(','):
        host = ipAddr
        servicePort = service + 'Port'
        port = eval(servicePort)  # 端口必须为数字
        service_status = KillProc(host, port).port_check()
        if service_status:
            print u"在%s服务器上服务端口为 %s 的 %s 服务正在运行......" % (host, port, service)
        else:
            print u"在%s服务器上服务端口为 %s 的 %s 服务未运行!" % (host, port, service)
Esempio n. 7
0
def stopserver():
    while True:
        inputserver = raw_input("请输入服务器名(多个以','隔开):").strip()
        for server_name in inputserver.split(","):
            if server_name in servers:
                server_port = int(servers[server_name])
                server_status = KillProc(ipAddr, server_port).port_check()
                if server_status is True:
                    optServer(server_name, 'STOP')
                elif server_status is not True:
                    print "%s 服务器已关闭!\n" % server_name
            else:
                print "%s 服务器不存在请重新输入!\n" % server_name
        break
Esempio n. 8
0
def stateserver():
    while True:
        inputserver = raw_input("请输入服务器名(多个以','隔开):").strip()
        print "%-14s     :%-4s" % ("服务器名称", "状态")
        for s in inputserver.split(","):
            if s in servers:
                server_port = servers[s]
                server_status = KillProc(ipAddr, server_port)
                if server_status:
                    print "%-14s :%-4s" % (s, "RUNNING")
                else:
                    print "%-14s :%-4s" % (s, "SHUTDOWN")
            else:
                print "%s 服务器不存在!\n" % s
        break
Esempio n. 9
0
def stopService():
    for service in serviceList.split(','):
        host = ipAddr
        port = int(eval(service + 'Port'))  # 端口必须为数字
        killserver = KillProc(host, port)
        killserver.killProc()