Exemplo n.º 1
0
def start_actor(actor_type, **kwargs):
    configure_logging(level=CONFIG.log_level)
    if CONFIG.sentry_enable:
        sentry_init(CONFIG.sentry_dsn)
    backdoor.setup()
    is_scheduler = actor_type == 'scheduler'
    actors = list(collect_actors(f'rssant_{actor_type}'))
    if not is_scheduler:
        actors.extend([
            do_update_registery,
            do_keepalive,
            do_dns_service_update,
        ])
        kwargs.update(
            on_startup=[on_startup],
            on_shutdown=[on_shutdown],
        )
    start_actor_cli(
        actor_type=actor_type,
        actors=actors,
        registery_node_spec=CONFIG.registery_node_spec,
        schema_compiler=schema_compiler,
        storage_dir_path=CONFIG.actor_storage_path,
        storage_compact_wal_delta=CONFIG.actor_storage_compact_wal_delta,
        queue_max_complete_size=CONFIG.actor_queue_max_complete_size,
        max_retry_time=CONFIG.actor_max_retry_time,
        max_retry_count=CONFIG.actor_max_retry_count,
        token=CONFIG.actor_token,
        **kwargs
    )
Exemplo n.º 2
0
def create_app():
    configure_logging(level=CONFIG.log_level)
    api = web.Application()
    api.router.add_routes(routes)
    app = web.Application()
    app.add_subapp('/api/v1', api)
    setup_aiojobs(app, limit=5000, pending_limit=5000)
    return app
Exemplo n.º 3
0
def main(pid=None, verbose=False):
    level = logging.DEBUG if verbose else logging.INFO
    configure_logging(level=level)
    sock = None
    if pid is None:
        pid, sock = connect_first_available_server()
    if pid is None:
        raise click.BadOptionUsage('pid', "Server PID is required!")
    shell = BackdoorShell(pid, sock=sock)
    shell.interact()
Exemplo n.º 4
0
def create_app():
    configure_logging(level=CONFIG.log_level)
    backdoor.setup()
    if CONFIG.sentry_enable:
        sentry_sdk.init(
            dsn=CONFIG.sentry_dsn,
            integrations=[AioHttpIntegration()]
        )
    api = web.Application()
    api.router.add_routes(routes)
    app = web.Application()
    app.add_subapp('/api/v1', api)
    setup_aiojobs(app, limit=5000, pending_limit=5000)
    return app
Exemplo n.º 5
0
        r = await ctx.ask('worker.local_ask', {'message': 'ping'},
                          dst_node=node.name)
        LOG.info('ask node {} done: {}'.format(node.name, r))


@actor('registery.query')
async def do_query(ctx: ActorContext) -> T.dict(nodes=T.list(NodeSpecSchema)):
    return dict(nodes=ctx.registery.to_spec())


ACTORS = collect_actors(__name__)


def main():
    backdoor.setup()
    app = ActorNode(
        actors=ACTORS,
        port=8081,
        name='registery',
        storage_dir_path='data/actorlib_example_registery',
    )
    app.run()


if __name__ == "__main__":
    from rssant_common.logger import configure_logging
    from actorlib.sentry import sentry_init
    configure_logging(enable_loguru=True, level='DEBUG')
    sentry_init()
    main()
Exemplo n.º 6
0
#!/usr/bin/env python
import sys
import time

import rssant_common.django_setup  # noqa:F401
from rssant_config import CONFIG
from rssant_common.logger import configure_logging

##
if __name__ == '__main__':
    try:
        from django.core.management import execute_from_command_line
    except ImportError as exc:
        raise ImportError(
            "Couldn't import Django. Are you sure it's installed and "
            "available on your PYTHONPATH environment variable? Did you "
            "forget to activate a virtual environment?") from exc
    configure_logging(level=CONFIG.log_level)
    while True:
        try:
            execute_from_command_line(sys.argv)
        except Exception as ex:
            print(f'* {type(ex).__name__}: {ex}')
            time.sleep(3)
        else:
            break
##
Exemplo n.º 7
0
Arquivo: cli.py Projeto: zuzhi/rssant
def update(debug):
    """update cacert"""
    if debug:
        configure_logging(level='DEBUG')
    CacertHelper.update()
Exemplo n.º 8
0
django.contrib.flatpages.*
django.contrib.redirects.*
django.contrib.gis.*
django.db.*oracle*
django.db.*mysql*
tornado.platform.windows
coreschema.encodings.corejson
readability.compat.two
nltk.tokenize.nist
nltk.twitter*
nltk.book*
nltk.app*
numpy.ma.version*
prompt_toolkit.*win*
gunicorn.workers.*gevent*
whitenoise.django*
"""

if __name__ == "__main__":
    if IS_GEN:
        configure_logging(level='DEBUG')
        traveler = ModuleTraveler(ignore=IGNORE)
        traveler.run()
    else:
        render_graph(
            input_filepath=INPUT_FILEPATH,
            output_filepath='data/rssant_module_graph.pdf',
            modules_filepath='data/rssant_modules.txt',
            threshold=0,
        )
Exemplo n.º 9
0
            msg = ''
            if last_code is not None:
                r = eval(last_code, self.globals, None)
                if r is None:
                    msg = ''
                else:
                    msg = repr(r) + '\n'
        except Exception as ex:
            return BackdoorResponse(False, self._format_exception(ex))
        print_buffer = self.take_print_buffer()
        return BackdoorResponse(True, print_buffer + msg)

    def process(self, request: dict):
        request = BackdoorRequest(request['command'], request['params'])
        LOG.info(f'backdoor server process request {request}')
        command = 'command_{}'.format(request.command)
        if hasattr(self, command):
            response = getattr(self, command)(**request.params)
        else:
            response = BackdoorResponse(False, f"No such command: {request.command}\n")
        LOG.info(f'backdoor server sending response {response}')
        return response.to_dict()


if __name__ == "__main__":
    from rssant_common.logger import configure_logging
    configure_logging()
    server = BackdoorServer()
    server.start()
    server.thread.join()
Exemplo n.º 10
0
def django_setup():
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'rssant.settings')
    django.setup()
    configure_logging(level='DEBUG')
Exemplo n.º 11
0
def get_wsgi_application():
    configure_logging(level=CONFIG.log_level)
    backdoor.setup()
    return _get_app()