Exemplo n.º 1
0
def main():
    global app
    global conf
    global fs
    global mailer
    global users

    setproctitle('firelet')
    args = parse_args()

    try:
        conf = ConfReader(fn=args.cf)
    except Exception as e:
        logging.error("Exception %s while reading configuration file %r", e,
                      args.cf)
        sys.exit(1)

    if args.repodir:
        conf.data_dir = args.repodir

    setup_logging(args, conf)

    log.success("Firelet started.")

    users = Users(d=conf.data_dir)
    mailer = Mailer(
        sender=conf.email_sender,
        recipients=conf.email_recipients,
        smtp_server=conf.email_smtp_server,
    )

    if conf.demo_mode:
        fs = DemoGitFireSet(conf.data_dir)
        log.info("Configuration loaded. Demo mode.")

    else:
        fs = GitFireSet(conf.data_dir)
        log.info("Configuration loaded.")

    log.info("%d users, %d hosts, %d rules, %d networks loaded.",
             *map(len, (users, fs.hosts, fs.rules, fs.networks))
             )

    logging.getLogger('paste.httpserver.ThreadPool').setLevel(logging.WARN)
    try:
        bottle.run(
            app=app,
            host=conf.listen_address,
            port=conf.listen_port,
            quiet=not args.debug,
            reloader=args.debug,
            server='auto'
        )
    except:
        logging.error("Unhandled exception", exc_info=True)
        raise  # TODO: wrap this around main() ?
               # is it a duplicate of HTTPError logging?

    # Run until terminated by SIGKILL or SIGTERM
    mailer.join()
Exemplo n.º 2
0
def main():
    global app
    global conf
    global fs
    global mailer
    global users

    setproctitle('firelet')
    args = parse_args()

    try:
        conf = ConfReader(fn=args.cf)
    except Exception as e:
        logging.error("Exception %s while reading configuration file %r", e,
                      args.cf)
        sys.exit(1)

    if args.repodir:
        conf.data_dir = args.repodir

    setup_logging(args, conf)

    log.success("Firelet started.")

    users = Users(d=conf.data_dir)
    mailer = Mailer(
        sender=conf.email_sender,
        recipients=conf.email_recipients,
        smtp_server=conf.email_smtp_server,
    )

    if conf.demo_mode:
        fs = DemoGitFireSet(conf.data_dir)
        log.info("Configuration loaded. Demo mode.")

    else:
        fs = GitFireSet(conf.data_dir)
        log.info("Configuration loaded.")

    log.info("%d users, %d hosts, %d rules, %d networks loaded.",
             *map(len, (users, fs.hosts, fs.rules, fs.networks)))

    logging.getLogger('paste.httpserver.ThreadPool').setLevel(logging.WARN)
    try:
        bottle.run(app=app,
                   host=conf.listen_address,
                   port=conf.listen_port,
                   quiet=not args.debug,
                   reloader=args.debug,
                   server='auto')
    except:
        logging.error("Unhandled exception", exc_info=True)
        raise  # TODO: wrap this around main() ?
        # is it a duplicate of HTTPError logging?

    # Run until terminated by SIGKILL or SIGTERM
    mailer.join()
Exemplo n.º 3
0
    try:
        run(
            app=app,
            host=conf.listen_address,
            port=conf.listen_port,
            quiet=not args.debug,
            reloader=args.debug,
            server='auto'
        )
    except:
        logging.error("Unhandled exception", exc_info=True)
        raise #TODO: wrap this around main() ?
              #is it a duplicate of HTTPError logging?

    # Run until terminated by SIGKILL or SIGTERM
    mailer.join()
    #daemoncontext.close()


if __name__ == "__main__":
    main()