def handle(self, *args, **options): """Handle the management command.""" daemonize = options.get('daemonize') pidfile = options.get('pidfile') stop = options.get('stop') # stop existing celeryd stopped = stop_celery_process(pidfile) if stop: if not stopped: print "No existing celeryd process" quit() print "Starting celeryd (%s)" % getpid() # safely turn this process into a daemon if daemonize: become_daemon() # write the pidfile if pidfile: with open(pidfile,'w+') as f: print "writing pidfile:",pidfile f.write(str(getpid())) run_worker(**options)
def handle(self, *args, **opts): pidfile = uid = gid = None if opts['pidfile']: pidfile = daemon.pidlockfile.PIDLockFile(opts['pidfile']) if opts['user']: uid = pwd.getpwnam(opts['user']).pw_uid if opts['group']: gid = grp.getgrnam(opts['group']).gr_gid del opts['pidfile'], opts['group'], opts['user'] with daemon.DaemonContext(pidfile=pidfile, uid=uid, gid=gid): run_worker(**opts)
def test_run_worker(self): p, cd.Worker = cd.Worker, Worker try: cd.run_worker(discard=True) finally: cd.Worker = p
def handle(self, *args, **options): """Handle the management command.""" run_worker(**options)
def run_celery(self): # Use celeryd's optparser. options = parse_options(sys.argv[2:]) run_worker(**vars(options))