Exemple #1
0
	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)
Exemple #2
0
    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)
Exemple #3
0
 def test_run_worker(self):
     p, cd.Worker = cd.Worker, Worker
     try:
         cd.run_worker(discard=True)
     finally:
         cd.Worker = p
Exemple #4
0
 def handle(self, *args, **options):
     """Handle the management command."""
     run_worker(**options)
Exemple #5
0
 def run_celery(self):
     # Use celeryd's optparser.
     options = parse_options(sys.argv[2:])
     run_worker(**vars(options))