Ticket #206: paste_script_daemon.patch

File paste_script_daemon.patch, 1.5 KB (added by osantana, 5 years ago)

Patch to fix this bug (proposal)

  • ../python/lib/python2.5/site-packages/PasteScript-1.3.6-py2.5.egg/paste/script/serve.py

    old new  
    2525 
    2626MAXFD = 1024 
    2727 
     28class DaemonizeException(Exception): 
     29    pass 
     30 
     31 
    2832class ServeCommand(Command): 
    2933 
    3034    min_args = 0 
     
    201205            writeable_log_file.close() 
    202206 
    203207        if self.options.daemon: 
    204             self.daemonize() 
     208            try: 
     209                self.daemonize() 
     210            except DaemonizeException, ex: 
     211                if self.verbose > 0: 
     212                    print str(ex) 
     213                return 
    205214 
    206215        if self.options.pid_file: 
    207216            self.record_pid(self.options.pid_file) 
     
    250259                **kw) 
    251260 
    252261    def daemonize(self): 
     262        if not self.options.pid_file: 
     263            self.options.pid_file = 'paster.pid' 
     264 
     265        pid = live_pidfile(self.options.pid_file) 
     266        if pid: 
     267            raise DaemonizeException("Daemon is already running (PID: %s)" % (pid,)) 
     268 
    253269        if self.verbose > 0: 
    254270            print 'Entering daemon mode' 
    255271        pid = os.fork() 
     
    287303        os.dup2(0, 1)  # standard output (1) 
    288304        os.dup2(0, 2)  # standard error (2) 
    289305         
    290         if not self.options.pid_file: 
    291             self.options.pid_file = 'paster.pid' 
    292306        if not self.options.log_file: 
    293307            self.options.log_file = 'paster.log' 
    294308