def startagent(port = myport): if agentdaemonize: print "Daemonizing" from hqdaemon import daemonize daemonize('/dev/null','/tmp/daemon.log','/tmp/daemon.log') if sys.platform.find("win32") != -1: import win32file win32file._setmaxstdio(2048) if use_ssl: print "Agent is started on port ", myport, " SSL is enabled " try: myContextFactory = ssl.DefaultOpenSSLContextFactory(agent_ssl_key, agent_ssl_cert) ctx = myContextFactory.getContext() # ctx.set_verify( SSL.VERIFY_PEER, verifyCallback) # ctx.set_options( SSL.OP_ALL ) # Since we have self-signed certs we have to explicitly # tell the server to trust them. ctx.load_verify_locations(agent_ssl_pem) except Exception, e: print "Failed to start, SSL keys are specified but do not exist ", e sys.exit(1) reactor.listenSSL(myport, ExecuteActionFactory(), myContextFactory) reactor.run(installSignalHandlers=False)
def startcontroller(): if hqconfig.daemonize: print "Daemonizing" from hqdaemon import daemonize daemonize('/dev/null','/tmp/daemon.log','/tmp/daemon.log') sess = get_controller_session() myserver = None try: myserver = sess.query(server).filter(server.SERVERID == myname).one() except Exception, e: myserver = server(SERVERID = myname) sess.add(myserver)
def startmonitor(): if hqconfig.daemonize: print "Daemonizing" from hqdaemon import daemonize daemonize('/dev/null','/tmp/daemon.log','/tmp/daemon.log') if sys.platform == "win32": rootdir = os.path.abspath('') else: rootdir = resource_filename("HQSystem", "") print rootdir print "Hosting on ", hqconfig.webport cherryconfig = { 'global': { 'server.socket_port': int(hqconfig.webport), 'server.socket_host': "0.0.0.0", 'server.thread_pool': 10, 'tools.sessions.on': True, 'tools.sessions.timeout': 6000, 'tools.staticdir.root': rootdir }, '/static': { 'tools.staticdir.on': True, 'tools.staticdir.dir': "static" } } cherrypy.config.update(cherryconfig) cherrypy.log.screen = False cherrypy.tree.mount(dispatch(), '/', cherryconfig) cherrypy.autoreload_on = True if hasattr(cherrypy.engine, 'signal_handler'): cherrypy.engine.signal_handler.handlers["SIGINT"] = cherrypy.engine.signal_handler.bus.exit cherrypy.engine.signal_handler.subscribe() print "Web Server Started" cherrypy.engine.start() cherrypy.engine.block()