Exemple #1
0
 def get_app(self):
     capp = celery.Celery()
     events = Events(capp)
     app = Flower(capp=capp, events=events,
                  options=options, handlers=handlers, **settings)
     app.delay = lambda method, *args, **kwargs: app_delay(method, *args, **kwargs)
     return app
Exemple #2
0
 def get_app(self):
     capp = celery.Celery()
     events = Events(capp)
     app = Flower(capp=capp, events=events,
                  options=options, handlers=handlers, **settings)
     app.delay = lambda method, *args, **kwargs: method(*args, **kwargs)
     return app
Exemple #3
0
 def get_app(self, capp=None):
     if not capp:
         capp = self._get_celery_app()
     events = Events(capp)
     app = Flower(capp=capp, events=events,
                  options=options, handlers=handlers, **settings)
     return app
Exemple #4
0
 def get_app(self, celery_app=None, events=None, state=None):
     celery_app = celery_app or celery.Celery()
     events = events or Events(celery_app)
     state = state or State(celery_app)
     self.app = Flower(celery_app=celery_app,
                       events=events,
                       state=state,
                       handlers=handlers,
                       **APP_SETTINGS)
     return self.app
Exemple #5
0
    def __init__(self):
        self.prog_name = 'flower'
        self.apply_options()
        self.app = Celery()
        self.app.config_from_object(flowerconfig)

        self.flower = Flower(capp=self.app,
                             options=options,
                             handlers=handlers,
                             **settings)
        self.flower.pool = self.flower.pool_executor_cls(
            max_workers=self.flower.max_workers)
        self.flower.events.start()
        self.flower.io_loop.add_future(
            control.ControlHandler.update_workers(app=self.flower),
            callback=lambda x: print('Successfully updated worker cache'))
        self.flower.started = True
        # self.flower.io_loop.start()
        self.print_banner('ssl_options' in settings)
Exemple #6
0
def get_wsgi_server():
    flower_app = Flower(capp=scheduler,
                        options=default_options,
                        handlers=handlers,
                        **settings)
    wsgi_app = tornado.wsgi.WSGIAdapter(flower_app)
    wsgi_app = ErrorMiddleware(wsgi_app, debug=debug_flag)
    wsgi_app = TransLogger(wsgi_app, setup_console_handler=debug_flag)

    return wsgi_app
Exemple #7
0
def main(argv=None):
    parse_command_line(argv)
    APP_SETTINGS['debug'] = options.debug

    celery_app = Celery()
    try:
        celery_app.config_from_object(CELERY_CONFIG)
    except ImportError:
        pass

    app = Flower(celery_app=celery_app, **APP_SETTINGS)

    print('> Visit me at http://localhost:%s' % options.port)
    logging.debug('Settings: %s' % pformat(APP_SETTINGS))

    try:
        app.start(options.port, inspect=options.inspect)
    except (KeyboardInterrupt, SystemExit):
        pass
Exemple #8
0
class FlowerServer():
    ENV_VAR_PREFIX = 'FLOWER_'

    def __init__(self):
        self.prog_name = 'flower'
        self.apply_options()
        self.app = Celery()
        self.app.config_from_object(flowerconfig)

        self.flower = Flower(capp=self.app,
                             options=options,
                             handlers=handlers,
                             **settings)
        self.flower.pool = self.flower.pool_executor_cls(
            max_workers=self.flower.max_workers)
        self.flower.events.start()
        self.flower.io_loop.add_future(
            control.ControlHandler.update_workers(app=self.flower),
            callback=lambda x: print('Successfully updated worker cache'))
        self.flower.started = True
        # self.flower.io_loop.start()
        self.print_banner('ssl_options' in settings)

    def apply_options(self):
        # parse the command line to get --conf option
        try:
            parse_config_file(os.path.abspath('flowerconfig.py'), final=False)
        except IOError:
            if os.path.basename(options.conf) != 'flowrconfig.py':
                raise

    def getWSGIServer(self):
        wsgi_app = tornado.wsgi.WSGIAdapter(self.flower)
        wsgi_app = ErrorMiddleware(wsgi_app, debug=debug_flag)
        wsgi_app = TransLogger(wsgi_app, setup_console_handler=debug_flag)

        return wsgi_app

    @staticmethod
    def is_flower_option(arg):
        name, _, value = arg.lstrip('-').partition("=")
        name = name.replace('-', '_')
        return hasattr(options, name)

    def is_flower_envvar(self, name):
        return name.startswith(self.ENV_VAR_PREFIX) and\
            name[len(self.ENV_VAR_PREFIX):].lower() in default_options

    def print_banner(self, ssl):
        print('Broker: %s', self.app.connection().as_uri())
        print('Registered tasks: \n%s', pformat(sorted(self.app.tasks.keys())))
        print('Settings: %s', pformat(settings))
 def get_app(self):
     capp = celery.Celery()
     events = Events(capp)
     app = Flower(capp=capp, events=events,
                  options=options, handlers=handlers, **settings)
     return app