Exemplo n.º 1
0
def main(argv):
    """
    The entry point of daemon_factory process

    :param argv: parameters given from command line
    """
    if (len(argv) != 3):
        usage()
        # TODO(takashi): returning non-zero value is better?
        return

    pipe_path = argv[0]
    log_level = argv[1]
    container_id = argv[2]

    # Initialize logger
    logger = start_logger("daemon_factory", log_level, container_id)
    logger.debug("Daemon factory started")
    SBus.start_logger("DEBUG", container_id=container_id)

    # Impersonate the swift user
    pw = pwd.getpwnam('swift')
    os.setresgid(pw.pw_gid, pw.pw_gid, pw.pw_gid)
    os.setresuid(pw.pw_uid, pw.pw_uid, pw.pw_uid)

    # create an instance of daemon_factory
    factory = daemon_factory(pipe_path, logger)

    # Start the main loop
    factory.main_loop(container_id)
Exemplo n.º 2
0
def main(argv):
    '''
    @summary: main
              The entry point. 
              - Initialize logger, 
              - impersonate to swift user,
              - create an instance of daemon_factory, 
              - start the main loop. 
    '''
    if (len(argv) != 2):
        usage()
        return
    
    pipe_path = argv[0]
    log_level = argv[1]
    logger = start_logger("daemon_factory", log_level)
    logger.debug("Daemon factory started")
    SBus.start_logger("DEBUG")
        
    # Impersonate the swift user
    pw = pwd.getpwnam('swift')
    os.setresgid(pw.pw_gid,pw.pw_gid,pw.pw_gid)
    os.setresuid(pw.pw_uid,pw.pw_uid,pw.pw_uid)

    
    factory = daemon_factory(pipe_path, logger)
    factory.main_loop()