Пример #1
0
def status(args):
    config_filename = read_config.DEFAULT_SERVER_CONFIG_FILE
    if args.config_filename is not None:
        config_filename = args.config_filename

    print "  == Akara status =="
    print "Configuration file:", repr(config_filename)
    try:
        settings, config = read_config.read_config(config_filename)
    except read_config.Error, err:
        print "** ERROR **:", str(err)
        raise SystemExit(1)
Пример #2
0
def status(args):
    config_filename = read_config.DEFAULT_SERVER_CONFIG_FILE
    if args.config_filename is not None:
        config_filename = args.config_filename

    print "  == Akara status =="
    print "Configuration file:", repr(config_filename)
    try:
        settings, config = read_config.read_config(config_filename)
    except read_config.Error, err:
        print "** ERROR **:", str(err)
        raise SystemExit(1)
Пример #3
0
def setup(args):
    if not args.config_filename:
        setup_config_file()
    settings, config = read_config.read_config(args.config_filename)

    dirname = os.path.dirname
    setup_directory_for("error log", dirname(settings["error_log"]))
    setup_directory_for("access log", dirname(settings["access_log"]))
    setup_directory_for("PID file", dirname(settings["pid_file"]))
    setup_directory_for("extension modules", settings["module_dir"])

    print
    print "Akara environment set up. To start Akara use:"
    print "    akara start"
Пример #4
0
def setup(args):
    if not args.config_filename:
        setup_config_file()
    settings, config = read_config.read_config(args.config_filename)

    dirname = os.path.dirname
    setup_directory_for("error log", dirname(settings["error_log"]))
    setup_directory_for("access log", dirname(settings["access_log"]))
    setup_directory_for("PID file", dirname(settings["pid_file"]))
    setup_directory_for("extension modules", settings["module_dir"])

    print
    print "Akara environment set up. To start Akara use:"
    print "    akara start"
Пример #5
0
def main(args):
    config_filename = args.config_filename
    debug = args.debug
    skip_pid_check = args.skip_pid_check

    first_time = True
    old_server_address = None
    sock = None
    while 1:
        # This is the main loop for the flup server.

        # Why is it a loop? A SIGHUP sent to the server
        # will shut down flup then reread the configuration
        # file, reload the extension modules, and start
        # the flup server again.

        try:
            settings, config = read_config.read_config(config_filename)
        except read_config.Error, err:
            logger.fatal(str(err))
            if first_time:
                raise SystemExit("Cannot start Akara. Exiting.")
            else:
                raise SystemExit("Cannot restart Akara. Exiting.")

        akara.raw_config = config

        # Establish the global configuration module
        set_global_config(settings)

        # In debug mode (-X), display all log messages.
        # Otherwise, use the configuration level
        if debug:
            logger.setLevel(logging.DEBUG)
        else:
            logger.setLevel(settings["log_level"])

        # Open this now, so any errors can be reported
        try:
            logger_config.set_logfile(settings["error_log"])
        except IOError, err:
            # Only give the 'akara setup' text here because it's where
            # we get to with an empty/nonexistant configuration file.
            logger.fatal("""\
Could not open the Akara error log:
   %s
Does that directory exist and is it writeable?
You may want to use 'akara setup' to set up the directory structure.""" % err)
            sys.exit(1)
Пример #6
0
def error_log_rotate(args):
    import datetime
    settings, config = read_config.read_config(args.config_filename)
    error_log = settings["error_log"]

    ext = ""
    i = 0
    timestamp = datetime.datetime.now().isoformat().split(".")[0]
    template = error_log + "." + timestamp
    archived_error_log = template
    while os.path.exists(archived_error_log):
        i += 1
        archived_error_log = template + "_" + str(i)

    try:
        os.rename(error_log, archived_error_log)
    except OSError, err:
        if not os.path.exists(error_log):
            print "No error log found at %r" % error_log
        else:
            raise
Пример #7
0
def error_log_rotate(args):
    import datetime

    settings, config = read_config.read_config(args.config_filename)
    error_log = settings["error_log"]

    ext = ""
    i = 0
    timestamp = datetime.datetime.now().isoformat().split(".")[0]
    template = error_log + "." + timestamp
    archived_error_log = template
    while os.path.exists(archived_error_log):
        i += 1
        archived_error_log = template + "_" + str(i)

    try:
        os.rename(error_log, archived_error_log)
    except OSError, err:
        if not os.path.exists(error_log):
            print "No error log found at %r" % error_log
        else:
            raise
Пример #8
0
def get_pid(args):
    try:
        settings, config = read_config.read_config(args.config_filename)
    except read_config.Error, err:
        raise SystemExit(str(err))
Пример #9
0
def get_pid(args):
    try:
        settings, config = read_config.read_config(args.config_filename)
    except read_config.Error, err:
        raise SystemExit(str(err))