Subversion Repositories SmartDukaan

Rev

Rev 19491 | Rev 19866 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 19491 Rev 19766
Line 22... Line 22...
22
	def __init__(self, pidfile, stdin='/dev/null', stdout='/dev/null', stderr='/dev/null'):
22
	def __init__(self, pidfile, stdin='/dev/null', stdout='/dev/null', stderr='/dev/null'):
23
		self.stdin = stdin
23
		self.stdin = stdin
24
		self.stdout = stdout
24
		self.stdout = stdout
25
		self.stderr = stderr
25
		self.stderr = stderr
26
		self.pidfile = pidfile
26
		self.pidfile = pidfile
-
 
27
		if stdin=='/dev/null':
27
		configure_logging(stdout)
28
			configure_logging(stdout)
28
	
29
	
29
	def daemonize(self):
30
	def daemonize(self):
30
		"""
31
		"""
31
		do the UNIX double-fork magic, see Stevens' "Advanced 
32
		do the UNIX double-fork magic, see Stevens' "Advanced 
32
		Programming in the UNIX Environment" for details (ISBN 0201563177)
33
		Programming in the UNIX Environment" for details (ISBN 0201563177)
Line 137... Line 138...
137
		"""
138
		"""
138
		You should override this method when you subclass Daemon. It will be called after the process has been
139
		You should override this method when you subclass Daemon. It will be called after the process has been
139
		daemonized by start() or restart().
140
		daemonized by start() or restart().
140
		"""
141
		"""
141
		pass
142
		pass
-
 
143
 
142
def configure_logging(logfile):
144
def configure_logging(logfile):
143
	if logfile is None:
-
 
144
		return
-
 
145
	fh = logging.FileHandler(logfile, 'w')
145
	fh = logging.FileHandler(logfile, 'w')
146
	formatter = logging.Formatter(logging.BASIC_FORMAT)
146
	formatter = logging.Formatter(logging.BASIC_FORMAT)
147
	fh.setFormatter(formatter)
147
	fh.setFormatter(formatter)
148
	root = logging.getLogger()
148
	root = logging.getLogger()
149
	root.setLevel(logging.DEBUG)
149
	root.setLevel(logging.ERROR)
150
	root.addHandler(fh)
150
	root.addHandler(fh)
151
151