|  | @@ -22,19 +22,39 @@
 | 
	
		
			
				|  |  |      `ERROR`, `CRITICAL`, or `FATAL`.
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  """
 | 
	
		
			
				|  |  | -from celery.bin.base import Command, Option
 | 
	
		
			
				|  |  | +from celery.bin.base import Command, Option, daemon_options
 | 
	
		
			
				|  |  | +from celery.platforms import create_daemon_context
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  class BeatCommand(Command):
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    def run(self, *args, **kwargs):
 | 
	
		
			
				|  |  | +    def run(self, detach=False, logfile=None, pidfile=None, uid=None,
 | 
	
		
			
				|  |  | +            gid=None, umask=None, working_directory=None, **kwargs):
 | 
	
		
			
				|  |  |          kwargs.pop("app", None)
 | 
	
		
			
				|  |  | -        return self.app.Beat(**kwargs).run()
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if not detach:
 | 
	
		
			
				|  |  | +            return self.app.Beat(logfile=logfile, **kwargs).run()
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        context, on_stop = create_daemon_context(
 | 
	
		
			
				|  |  | +                                logfile=logfile,
 | 
	
		
			
				|  |  | +                                pidfile=pidfile,
 | 
	
		
			
				|  |  | +                                uid=uid,
 | 
	
		
			
				|  |  | +                                gid=gid,
 | 
	
		
			
				|  |  | +                                umask=umask,
 | 
	
		
			
				|  |  | +                                working_directory=working_directory)
 | 
	
		
			
				|  |  | +        context.open()
 | 
	
		
			
				|  |  | +        try:
 | 
	
		
			
				|  |  | +            self.app.Beat(pidfile=pidfile, logfile=logfile, **kwargs).run()
 | 
	
		
			
				|  |  | +        finally:
 | 
	
		
			
				|  |  | +            on_stop()
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      def get_options(self):
 | 
	
		
			
				|  |  |          conf = self.app.conf
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          return (
 | 
	
		
			
				|  |  | +            Option('--detach',
 | 
	
		
			
				|  |  | +                default=False, action="store_true", dest="detach",
 | 
	
		
			
				|  |  | +                help="Detach and run in the background."),
 | 
	
		
			
				|  |  |              Option('-s', '--schedule',
 | 
	
		
			
				|  |  |                  default=conf.CELERYBEAT_SCHEDULE_FILENAME,
 | 
	
		
			
				|  |  |                  action="store", dest="schedule",
 | 
	
	
		
			
				|  | @@ -49,14 +69,12 @@ class BeatCommand(Command):
 | 
	
		
			
				|  |  |                  action="store", dest="scheduler_cls",
 | 
	
		
			
				|  |  |                  help="Scheduler class. Default is "
 | 
	
		
			
				|  |  |                       "celery.beat.PersistentScheduler"),
 | 
	
		
			
				|  |  | -            Option('-f', '--logfile', default=conf.CELERYBEAT_LOG_FILE,
 | 
	
		
			
				|  |  | -                action="store", dest="logfile",
 | 
	
		
			
				|  |  | -                help="Path to log file."),
 | 
	
		
			
				|  |  |              Option('-l', '--loglevel',
 | 
	
		
			
				|  |  |                  default=conf.CELERYBEAT_LOG_LEVEL,
 | 
	
		
			
				|  |  |                  action="store", dest="loglevel",
 | 
	
		
			
				|  |  |                  help="Loglevel. One of DEBUG/INFO/WARNING/ERROR/CRITICAL."),
 | 
	
		
			
				|  |  | -        )
 | 
	
		
			
				|  |  | +        ) + daemon_options(default_pidfile="celerybeat.pid",
 | 
	
		
			
				|  |  | +                           default_logfile=conf.CELERYBEAT_LOG_FILE)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  def main():
 |