コード例 #1
0
ファイル: worker.py プロジェクト: accek/sioworkers
def main():
    usage = "usage: %prog [options] [broker-url]"
    epilog = """\
The worker needs Filetracker server configured. If no FILETRACKER_URL is
present in the environment, a sensible default is generated, using the same
host as the Celery broker uses, with default Filetracker port."""
    parser = OptionParser(usage=usage, epilog=epilog)
    parser.disable_interspersed_args()

    app = Celery(loader=Loader)
    cmd = WorkerCommand(app)
    for x in cmd.get_options():
        parser.add_option(x)

    options, args = parser.parse_args()

    if len(args) > 1:
        parser.error("Unexpected arguments: " + " ".join(args[1:]))
    if args:
        broker_url = args[0]
        os.environ["CELERY_BROKER_URL"] = args[0]

    if "FILETRACKER_URL" not in os.environ:
        default_filetracker_host = None
        if "CELERY_BROKER_URL" in os.environ:
            default_filetracker_host = _host_from_url(os.environ["CELERY_BROKER_URL"])
        if not default_filetracker_host:
            default_filetracker_host = "127.0.0.1"
        os.environ["FILETRACKER_URL"] = "http://%s:%d" % (default_filetracker_host, DEFAULT_FILETRACKER_PORT)

    return cmd.run(**vars(options))
コード例 #2
0
ファイル: worker.py プロジェクト: neeraj9/sioworkers
def main():
    usage = "usage: %prog [options] [broker-url]"
    epilog = """\
The worker needs Filetracker server configured. If no FILETRACKER_URL is
present in the environment, a sensible default is generated, using the same
host as the Celery broker uses, with default Filetracker port."""
    parser = OptionParser(usage=usage, epilog=epilog)
    parser.disable_interspersed_args()

    os.environ.setdefault('CELERY_CONFIG_MODULE', 'sio.celery.default_config')
    app = Celery()
    cmd = WorkerCommand(app)
    for x in cmd.get_options():
        parser.add_option(x)

    options, args = parser.parse_args()

    if len(args) > 1:
        parser.error("Unexpected arguments: " + ' '.join(args[1:]))
    if args:
        broker_url = args[0]
        os.environ['CELERY_BROKER_URL'] = args[0]

    if 'FILETRACKER_URL' not in os.environ:
        default_filetracker_host = None
        if 'CELERY_BROKER_URL' in os.environ:
            default_filetracker_host = \
                    _host_from_url(os.environ['CELERY_BROKER_URL'])
        if not default_filetracker_host:
            default_filetracker_host = '127.0.0.1'
        os.environ['FILETRACKER_URL'] = 'http://%s:%d' \
                % (default_filetracker_host, DEFAULT_FILETRACKER_PORT)

    return cmd.run(**vars(options))
コード例 #3
0
ファイル: celeryd.py プロジェクト: firemyst/pyramid_celery
def main(argv=sys.argv): # pragma: no cover
    if len(argv) != 2:
        usage(argv)

    config_uri = argv[1]

    env = bootstrap(config_uri)
    worker = WorkerCommand(app=Celery(env))
    worker.run()
コード例 #4
0
ファイル: celeryd.py プロジェクト: xflash96/pyramid_celery
def main(argv=sys.argv): # pragma: no cover
    if len(argv) < 2:
        usage(argv)

    config_uri = argv[1]
    pcelery_setup(config_uri)

    worker = WorkerCommand(app=pyramid_celery.celery)
    worker.execute_from_commandline(argv=argv[1:])
コード例 #5
0
ファイル: command.py プロジェクト: inercia/celery-worker-skel
def main():
    # Fix for setuptools generated scripts, so that it will
    # work with multiprocessing fork emulation.
    # (see multiprocessing.forking.get_preparation_data())
    if __name__ != '__main__':  # pragma: no cover
        sys.modules['__main__'] = sys.modules[__name__]
    from billiard import freeze_support
    freeze_support()
    worker = WorkerCommand()
    worker.execute_from_commandline()
コード例 #6
0
 def test_setup_concurrency_very_early(self):
     x = WorkerCommand()
     x.run = Mock()
     with self.assertRaises(ImportError):
         x.execute_from_commandline(['celeryd', '-P', 'xyzybox'])
コード例 #7
0
 def test_windows_B_option(self):
     celery = Celery(set_as_current=False)
     celery.IS_WINDOWS = True
     with self.assertRaises(SystemExit):
         WorkerCommand(app=celery).run(beat=True)
コード例 #8
0
 def test_parse_options(self):
     cmd = WorkerCommand()
     cmd.app = current_app
     opts, args = cmd.parse_options('celeryd', ['--concurrency=512'])
     self.assertEqual(opts.concurrency, 512)
コード例 #9
0
 def test_unknown_loglevel(self):
     with self.assertRaises(SystemExit):
         WorkerCommand(app=self.app).run(loglevel='ALIEN')
     worker1 = self.Worker(loglevel=0xFFFF)
     self.assertEqual(worker1.loglevel, 0xFFFF)
コード例 #10
0
 def test_no_loglevel(self):
     app = Celery(set_as_current=False)
     app.Worker = Mock()
     WorkerCommand(app=app).run(loglevel=None)
コード例 #11
0
 def test_invalid_loglevel_gives_error(self):
     x = WorkerCommand(app=Celery(set_as_current=False))
     with self.assertRaises(SystemExit):
         x.run(loglevel='GRIM_REAPER')
コード例 #12
0
 def test_parse_options(self):
     cmd = WorkerCommand()
     opts, args = cmd.parse_options("celeryd", ["--concurrency=512"])
     self.assertEqual(opts.concurrency, 512)
コード例 #13
0
 def command(self):
     from celery.bin.celeryd import WorkerCommand
     w = WorkerCommand()
     w.execute_from_commandline(['celeryd'] + sys.argv[3:])
コード例 #14
0
 def update_parser(self, args):
     from celery.bin.celeryd import WorkerCommand
     w = WorkerCommand()
     w.setup_app_from_commandline(['celeryd'])
     for x in w.get_options():
         self.parser.add_option(x)
コード例 #15
0
ファイル: celery.py プロジェクト: AlterTap/flask-celery
 def worker(self):
     from celery.bin.celeryd import WorkerCommand
     return WorkerCommand(app=Celery(self.app))
コード例 #16
0
ファイル: __init__.py プロジェクト: serchaos/openspending
 def update_parser(self, args):
     from celery.bin.celeryd import WorkerCommand
     w = WorkerCommand()
     w.setup_app_from_commandline(['celeryd'])
     for x in w.get_options():
         self.parser.add_option(x)
コード例 #17
0
 def worker_main(self, argv=None):
     """Run :program:`celeryd` using `argv`.  Uses :data:`sys.argv`
     if `argv` is not specified."""
     from celery.bin.celeryd import WorkerCommand
     return WorkerCommand(app=self).execute_from_commandline(argv)
コード例 #18
0
ファイル: test_celeryd.py プロジェクト: OddBloke/celery
 def test_parse_options(self):
     cmd = WorkerCommand()
     cmd.app = current_app
     opts, args = cmd.parse_options("celeryd", ["--concurrency=512"])
     self.assertEqual(opts.concurrency, 512)
コード例 #19
0
 def worker(self):
     from celery.bin.celeryd import WorkerCommand
     return WorkerCommand(app=current_celery())
コード例 #20
0
ファイル: __init__.py プロジェクト: serchaos/openspending
 def command(self):
     from celery.bin.celeryd import WorkerCommand
     w = WorkerCommand()
     w.execute_from_commandline(['celeryd'] + sys.argv[3:])