Esempio n. 1
0
def _start_server_process_4real(server, options_override=None):
    server_dir_exists = mk_server_dir(server)
    first_time = not server_dir_exists

    # generate key file if needed
    if server.needs_repl_key():
        get_generate_key_file(server)

    # create the start command line
    start_cmd = generate_start_command(server, options_override)

    start_cmd_str = " ".join(start_cmd)
    first_time_msg = " for the first time" if first_time else ""

    log_info("Starting server '%s'%s..." % (server.id, first_time_msg))
    log_info("\nExecuting command:\n%s\n" % start_cmd_str)

    child_process_out = None
    if server.is_fork():
        child_process_out = subprocess.PIPE

    global __mongod_pid__
    global __current_server__

    parent_mongod = create_subprocess(start_cmd,
                                      stdout=child_process_out,
                                      preexec_fn=server_process_preexec)

    if server.is_fork():
        __mongod_pid__ = get_forked_mongod_pid(parent_mongod)
    else:
        __mongod_pid__ = parent_mongod.pid

    __current_server__ = server
    return __mongod_pid__
Esempio n. 2
0
def tail_server_log(server):
    try:
        logpath = server.get_log_file_path()
        # touch log file to make sure it exists
        log_verbose("Touching log file '%s'" % logpath)
        execute_command(["touch", logpath])

        tail_cmd = ["tail", "-f", logpath]
        log_verbose("Executing command: %s" % (" ".join(tail_cmd)))
        return create_subprocess(tail_cmd)
    except Exception, e:
        log_exception(e)
        log_error("Unable to tail server log file. Cause: %s" % e)
        return None
Esempio n. 3
0
def tail_server_log(server):
    try:
        logpath = server.get_log_file_path()
        # touch log file to make sure it exists
        log_verbose("Touching log file '%s'" % logpath)
        execute_command(["touch", logpath])

        tail_cmd = ["tail", "-f", logpath]
        log_verbose("Executing command: %s" % (" ".join(tail_cmd)))
        return create_subprocess(tail_cmd)
    except Exception, e:
        log_exception(e)
        log_error("Unable to tail server log file. Cause: %s" % e)
        return None
Esempio n. 4
0
def _start_server_process_4real(server,
                                options_override=None,
                                standalone=False):
    mk_server_home_dir(server)
    # if the pid file is not created yet then this is the first time this
    # server is started (or at least by mongoctl)

    first_time = os.path.exists(server.get_pid_file_path())

    # generate key file if needed
    gen_key_file = config.get_generate_key_file_conf(default=True)
    if server.needs_repl_key() and gen_key_file:
        get_generate_key_file(server)

    # create the start command line
    start_cmd = generate_start_command(server,
                                       options_override=options_override,
                                       standalone=standalone)

    start_cmd_str = start_command_display(start_cmd)
    first_time_msg = " for the first time" if first_time else ""

    log_info("Starting server '%s'%s..." % (server.id, first_time_msg))
    log_info("\nExecuting command:\n%s\n" % start_cmd_str)

    child_process_out = None
    if server.is_fork():
        child_process_out = subprocess.PIPE

    global __mongod_pid__
    global __current_server__

    parent_mongod = create_subprocess(start_cmd,
                                      stdout=child_process_out,
                                      preexec_fn=server_process_preexec,
                                      close_fds=True)

    # check if the process was created successfully

    if server.is_fork():
        __mongod_pid__ = get_forked_mongod_pid(parent_mongod)
    else:
        __mongod_pid__ = parent_mongod.pid

    __current_server__ = server
    return __mongod_pid__
Esempio n. 5
0
def _start_server_process_4real(server, options_override=None, standalone=False):
    mk_server_home_dir(server)
    # if the pid file is not created yet then this is the first time this
    # server is started (or at least by mongoctl)

    first_time = os.path.exists(server.get_pid_file_path())

    # generate key file if needed
    gen_key_file = config.get_generate_key_file_conf(default=True)
    if server.needs_repl_key() and gen_key_file:
        get_generate_key_file(server)

    # create the start command line
    start_cmd = generate_start_command(server, options_override=options_override,
                                       standalone=standalone)

    start_cmd_str = start_command_display(start_cmd)
    first_time_msg = " for the first time" if first_time else ""

    log_info("Starting server '%s'%s..." % (server.id, first_time_msg))
    log_info("\nExecuting command:\n%s\n" % start_cmd_str)

    child_process_out = None
    if server.is_fork():
        child_process_out = subprocess.PIPE

    global __mongod_pid__
    global __current_server__

    parent_mongod = create_subprocess(start_cmd,
                                      stdout=child_process_out,
                                      preexec_fn=server_process_preexec,
                                      close_fds=True)

    # check if the process was created successfully

    if server.is_fork():
        __mongod_pid__ = get_forked_mongod_pid(parent_mongod)
    else:
        __mongod_pid__ = parent_mongod.pid

    __current_server__ = server
    return __mongod_pid__
Esempio n. 6
0
def _start_server_process_4real(server, options_override=None):
    mk_server_home_dir(server)
    # if the pid file is not created yet then this is the first time this
    # server is started (or at least by mongoctl)
    first_time = os.path.exists(server.get_pid_file_path())

    # generate key file if needed
    if server.needs_repl_key():
        get_generate_key_file(server)

    # create the start command line
    start_cmd = generate_start_command(server, options_override)

    start_cmd_str = " ".join(start_cmd)
    first_time_msg = " for the first time" if first_time else ""

    log_info("Starting server '%s'%s..." % (server.id, first_time_msg))
    log_info("\nExecuting command:\n%s\n" % start_cmd_str)

    child_process_out = None
    if server.is_fork():
        child_process_out = subprocess.PIPE

    global __mongod_pid__
    global __current_server__

    #DETACHED_PROCESS = 0x00000008
    parent_mongod = create_subprocess(start_cmd,
                                      stdout=child_process_out,
                                      preexec_fn=server_process_preexec)
                                      #creationflags=DETACHED_PROCESS)



    if server.is_fork():
        __mongod_pid__ = get_forked_mongod_pid(parent_mongod)
    else:
        __mongod_pid__ = parent_mongod.pid

    __current_server__ = server
    return __mongod_pid__
Esempio n. 7
0
def _start_server_process_4real(server, options_override=None):
    server_dir_exists = mk_server_dir(server)
    first_time = not server_dir_exists

    # generate key file if needed
    if server.needs_repl_key():
        get_generate_key_file(server)

    # create the start command line
    start_cmd = generate_start_command(server, options_override)

    start_cmd_str = " ".join(start_cmd)
    first_time_msg = " for the first time" if first_time else ""

    log_info("Starting server '%s'%s..." % (server.id, first_time_msg))
    log_info("\nExecuting command:\n%s\n" % start_cmd_str)

    child_process_out = None
    if server.is_fork():
        child_process_out = subprocess.PIPE

    global __mongod_pid__
    global __current_server__

    parent_mongod = create_subprocess(start_cmd,
                                      stdout=child_process_out,
                                      preexec_fn=server_process_preexec)



    if server.is_fork():
        __mongod_pid__ = get_forked_mongod_pid(parent_mongod)
    else:
        __mongod_pid__ = parent_mongod.pid

    __current_server__ = server
    return __mongod_pid__