Example #1
0
def start():
    """Main entry point into the monitor server"""
    
    # Read configuration
    config_init()
    
    # Daemonise if necessary
    handleDaemonise()
    
    log_info("CRCnet Monitor v%s (r%s)" % (ccsd_version, ccsd_revision))
    
    # Setup signal handling 	 	 
    signal.signal(signal.SIGTERM, sighndlr) 	 	 
    signal.signal(signal.SIGINT, sighndlr) 
    
    # Initialise modules
    modules = loadModules(CCSD_CLIENT)
    
    # Call any module initialisation functions
    for mod in modules:
        if hasattr(mod, "ccs_init"):
            mod.ccs_init()
    
    # Setup Server - starts a mainloop
    startCCSDServer(None, None, None)
Example #2
0
File: ccsd.py Project: libzz/amiral
def start():
    """Main entry point into the configuration daemon"""

    # Read configuration
    config_init()

    # Daemonise if necessary
    handleDaemonise()

    log_info("CRCnet Configuration System Daemon v%s (r%s)" % (ccsd_version, ccsd_revision))

    # Initialise sessions
    initSessions()

    # Initialise modules
    modules = loadModules(CCSD_SERVER)
    for mod in modules:
        # Look for class methods to be registered with XMLRPC
        processClassMethods(mod)

    # Cfengine Configuration / Template System
    try:
        ccsd_cfengine.initCFengine()
    except:
        log_fatal("Failed to initialise CFengine integration!", sys.exc_info())

    # Initialise services
    processClassMethods(ccsd_service)

    # Initialise the certificate authority
    try:
        ccsd_ca.init_ca()
    except:
        log_fatal("Failed to initialise the CA!", sys.exc_info())

    # Call any module initialisation functions
    for mod in modules:
        if hasattr(mod, "ccs_init"):
            mod.ccs_init()

    # Load the server key/cert from the certification authority
    ca = ccsd_ca.ccs_ca()
    key = None
    cert = None
    cacert = None
    try:
        key = ca.loadkey("server-key.pem")
    except:
        log_fatal("Unable to read server key!", sys.exc_info())
    try:
        cert = ca.loadcert("server-cert.pem")
    except ccs_ca_error:
        log_fatal("Unable to read server certificate!", sys.exc_info())

    # Load the ca cert(s) too
    try:
        cacert = ca.loadCACerts()
    except:
        log_fatal("CA certificate is not available!", sys.exc_info())
    del ca

    # Setup RPC Server - starts a mainloop via twisted.internet.reactor
    startCCSDServer(key, cert, cacert)