Exemple #1
0
def appOverload(s,logs):
    try:
        reload(DAL)
        reload(conf)
        logs.debug('载入操作类成功')
        apps = DAL.apps(logs,tomcat_dict=conf.tomcat_dict)
        return apps
    except Exception as e:
        logs.error('载入操作类失败 %s'%e.message)
        s.send_json({'data':{'message':'载入操作类失败 %s'%e.message},'mode':False})
        return False
        pass
Exemple #2
0
def appOverload(s, logs):
    try:
        reload(DAL)
        reload(conf)
        logs.debug('载入操作类成功')
        apps = DAL.apps(logs, tomcat_dict=conf.tomcat_dict)
        return apps
    except Exception as e:
        logs.error('载入操作类失败 %s' % e.message)
        s.send_json({
            'data': {
                'message': '载入操作类失败 %s' % e.message
            },
            'mode': False
        })
        return False
        pass
Exemple #3
0
def apps_local(logs):
    def recv(s):
        try:
            msg = s.recv_json()
            logs.debug('接收信息成功:%s' % (msg))
            return msg
        except Exception as e:
            logs.warning("接收信息失败error :%s" % (e.message))
            return {'Mode': None, 'data': {'message': e.message}}

    logs.debug('守护进程开始 pid %d' % os.getpid())
    Counter = 0
    try:
        c = zmq.Context(1)
        s = c.socket(zmq.REP)
        s.bind('tcp://%s:%s' % (conf.IP, conf.PORT))
        logs.info('%s:%s 启动成功' % (conf.IP, conf.PORT))
    except Exception as e:
        logs.error('%s:%s 启动失败 失败原因:%s' % (conf.IP, conf.PORT, e.message))
    while True:
        logs.debug('开始接受第%s次' % (Counter))
        msg = recv(s)
        apps = DAL.apps(logs, tomcat_dict=conf.tomcat_dict)
        try:
            if msg['mode'] == None:
                s.send(msg)
            elif msg['mode'] == 'exit':
                logs.info("接收到客户端发来退出信息.开始退出声明")
                if msg['data']['data'] == '123456':
                    msg['data']['message'] = '关闭密码正确.开始关闭'
                    logs.warning(msg['data']['message'])
                    s.send_json(msg)
                    break
                else:
                    msg['data']['message'] = '关闭密码错误'
                    logs.error(msg['data']['message'])
                    s.send_json(msg)
        except Exception as e:
            logs.error("服务端未知错误 %s" % (e.message))
        try:
            getattr(apps, msg['mode'])(data=msg['data'])
            msg['data']['message'] = '%s操作成功' % (msg['data']['name'])
            s.send_json(msg)
        except Exception as e:
            msg['data']['message'] = e.message
            logs.error(msg['data']['message'])
            s.send_json(msg)
            pass

        try:
            reload(DAL)
            reload(conf)
            logs.debug('载入操作类成功')
        except Exception as e:
            logs.error('载入操作类失败 %s' % e.message)
            break
            pass
        '''if msg:
            args_array = msg.split('|')
            reposName = args_array[0]
            auth = args_array[1]
            userName = args_array[2]
            branchesName = args_array[3]
            if reposName == 'it' or reposName == 'trade' or reposName == 'tech-arch':
                pass
                #javaAuthChange(reposName,auth,userName,branchesName)
            if reposName == 'php':
                pass
                #svnAuthChange(reposName,auth,userName,branchesName)'''
        #s.send(msg)
        Counter += 1
        time.sleep(1)
    logs.debug('守护进程退出 pid %d' % os.getpid())
Exemple #4
0
def apps_local(logs):
    def recv(s):
        try:
            msg = s.recv_json()
            logs.debug('接收信息成功:%s' %(msg))
            return msg
        except Exception as e:
            logs.warning("接收信息失败error :%s"%(e.message))
            return {'Mode':None,'data':{'message':e.message}}
    logs.debug('守护进程开始 pid %d' % os.getpid())
    Counter = 0
    try:
        c = zmq.Context(1)
        s = c.socket(zmq.REP)
        s.bind('tcp://%s:%s'%(conf.IP, conf.PORT))
        logs.info('%s:%s 启动成功'%(conf.IP, conf.PORT))
    except Exception as e:
        logs.error('%s:%s 启动失败 失败原因:%s'%(conf.IP, conf.PORT,e.message))
    while True:
        logs.debug('开始接受第%s次' %(Counter))
        msg = recv(s)
        apps = DAL.apps(logs,tomcat_dict=conf.tomcat_dict)
        try:
            if msg['mode']  == None:
                s.send(msg)
            elif msg['mode'] == 'exit':
                logs.info("接收到客户端发来退出信息.开始退出声明")
                if msg['data']['data'] == '123456':
                    msg['data']['message']  = '关闭密码正确.开始关闭'
                    logs.warning(msg['data']['message'])
                    s.send_json(msg)
                    break
                else:
                    msg['data']['message']  = '关闭密码错误'
                    logs.error(msg['data']['message'])
                    s.send_json(msg)
        except Exception as e:
            logs.error("服务端未知错误 %s"%(e.message))
        try:
            getattr(apps, msg['mode'])(data=msg['data'])
            msg['data']['message'] = '%s操作成功'%(msg['data']['name'])
            s.send_json(msg)
        except Exception as e:
            msg['data']['message'] = e.message
            logs.error(msg['data']['message'])
            s.send_json(msg)
            pass

        try:
            reload(DAL)
            reload(conf)
            logs.debug('载入操作类成功')
        except Exception as e:
            logs.error('载入操作类失败 %s'%e.message)
            break
            pass


        '''if msg:
            args_array = msg.split('|')
            reposName = args_array[0]
            auth = args_array[1]
            userName = args_array[2]
            branchesName = args_array[3]
            if reposName == 'it' or reposName == 'trade' or reposName == 'tech-arch':
                pass
                #javaAuthChange(reposName,auth,userName,branchesName)
            if reposName == 'php':
                pass
                #svnAuthChange(reposName,auth,userName,branchesName)'''
        #s.send(msg)
        Counter += 1
        time.sleep(1)
    logs.debug('守护进程退出 pid %d' % os.getpid())