Beispiel #1
0
def main(port):
    "starts betanin"
    _print_meta_info()
    # ensure config exists and is valid
    main_config.ensure()
    secret_key.ensure()
    # setup stop
    signal.signal(signal.SIGINT, _stop)
    signal.signal(signal.SIGTERM, _stop)
    # setup start
    gevent.hub.Hub.NOT_ERROR = (OSError, SystemExit)
    flask_app = application.create()
    start_job = lambda module, *args, **kwargs: _make_starter(
        flask_app, module, *args, **kwargs
    )
    # start sync jobs
    start_job(migrate_database)
    start_job(retry_old_imports)
    # start async jobs
    gevent.joinall(
        (
            start_job(register_notifications),
            start_job(import_torrents),
            start_job(serve_web, port),
        )
    )
Beispiel #2
0
def main(host, port):
    "starts betanin"
    _print_meta_info()
    _ensure_config()
    _ensure_secret_key()

    signal.signal(signal.SIGINT, _stop)
    signal.signal(signal.SIGTERM, _stop)

    gevent.hub.Hub.NOT_ERROR = (OSError, SystemExit)

    app = application.create()
    with app.app_context():
        _migrate_database()
        _retry_old_imports()
        _register_notifications()

    conf = conf_betanin.read()
    num_imports = conf_betanin.find_num_parallel_jobs(conf)
    gevent.joinall(
        (
            *(_start_job(app, import_torrents) for _ in range(num_imports)),
            _start_job(app, serve_web, host, port),
        )
    )
Beispiel #3
0
def main():
    "starts the betanin shell"
    app = application.create()
    with app.app_context():
        console = code.InteractiveConsole(
            locals={
                "Line": Line,
                "Torrent": Torrent,
                "app": app,
                "DB": DB,
                "exit": Exit(),
            })
        console.interact(banner=WELCOME_MESSAGE)