Make daemonize a real static method.

Add chdir option that defaults to '/' instead of passing self and
referencing self.web.
This commit is contained in:
Joel Martin 2011-04-30 16:34:56 -05:00
parent 65c1d8073c
commit ff470ad704
1 changed files with 4 additions and 4 deletions

View File

@ -89,10 +89,10 @@ Connection: Upgrade\r
# WebSocketServer static methods
#
@staticmethod
def daemonize(self, keepfd=None):
def daemonize(keepfd=None, chdir='/'):
os.umask(0)
if self.web:
os.chdir(self.web)
if chdir:
os.chdir(chdir)
else:
os.chdir('/')
os.setgid(os.getgid()) # relinquish elevations
@ -357,7 +357,7 @@ Connection: Upgrade\r
lsock.listen(100)
if self.daemon:
self.daemonize(self, keepfd=lsock.fileno())
self.daemonize(keepfd=lsock.fileno(), chdir=self.web)
self.started() # Some things need to happen after daemonizing