Commits

Ian Bicking committed a115d42

Daemonize when using start/restart (as was documented). Fix http://trac.pythonpaste.org/pythonpaste/ticket/424

Comments (0)

Files changed (1)

paste/script/serve.py

     summary = "Serve the described application"
     description = """\
     This command serves a web application that uses a paste.deploy
-    configuration file for the server and application.  
-    
+    configuration file for the server and application.
+
     If start/stop/restart is given, then --daemon is implied, and it will
     start (normal operation), stop (--stop-daemon), or do both.
 
     You can also include variable assignments like 'http_port=8080'
     and then use %(http_port)s in your config files.
     """
-    
+
     # used by subclasses that configure apps and servers differently
     requires_config_file = True
 
                 return result
             if cmd == 'stop':
                 return result
+            self.options.daemon = True
+
+        if cmd == 'start':
+            self.options.daemon = True
 
         app_name = self.options.app_name
         vars = self.parse_vars(restvars)
             jython_monitor.periodic_reload()
         else:
             serve()
-    
+
     def loadserver(self, server_spec, name, relative_to, **kw):
             return loadserver(
                 server_spec, name=name,
                 relative_to=relative_to, **kw)
-    
+
     def loadapp(self, app_spec, name, relative_to, **kw):
             return loadapp(
                 app_spec, name=name, relative_to=relative_to,
         # Duplicate standard input to standard output and standard error.
         os.dup2(0, 1)  # standard output (1)
         os.dup2(0, 2)  # standard error (2)
-        
+
     def record_pid(self, pid_file):
         pid = os.getpid()
         if self.verbose > 1:
                         os.kill(proc.pid, signal.SIGTERM)
                     except (OSError, IOError):
                         pass
-                
+
             if reloader:
                 # Reloader always exits with code 3; but if we are
                 # a monitor, any exit code will restart
             os.setgid(gid)
         if uid:
             os.setuid(uid)
-            
+
 class LazyWriter(object):
 
     """
         self.fileobj = None
         self.lock = threading.Lock()
         self.mode = mode
-        
+
     def open(self):
         if self.fileobj is None:
             self.lock.acquire()
             return None
     else:
         return None
-        
+
 def _remove_pid_file(written_pid, filename, verbosity):
     current_pid = os.getpid()
     if written_pid != current_pid:
         print 'Stale PID left in file: %s (%e)' % (filename, e)
     else:
         print 'Stale PID removed'
-        
-            
+
+
 def ensure_port_cleanup(bound_addresses, maxtries=30, sleeptime=2):
     """
     This makes sure any open ports are closed.
     def handle_term(signo, frame):
         raise SystemExit
     signal.signal(signal.SIGTERM, handle_term)
-    
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.