1
0
mirror of https://github.com/r4sas/py-i2phosts synced 2025-01-22 04:24:15 +00:00

py-i2phosts-master: improve log messages

This commit is contained in:
Hidden Z 2010-11-07 19:41:02 +00:00
parent 42964c6047
commit 7b400f6a29

View File

@ -42,7 +42,7 @@ class CheckerThread(Thread):
def run_prog(prog):
try:
log.info('launching %s', prog)
log.info('starting: %s', prog)
sp_args = [prog]
if args.debug or args.verbose:
sp_args.append('-d')
@ -50,10 +50,10 @@ def run_prog(prog):
except OSError, e:
log.error('failed to exec %s: %s', prog, e)
if e.errno == errno.ENOENT:
log.error(' maybe it isn\'t in PATH')
log.error(' maybe it isn\'t in PATH?')
else:
p.wait()
log.info('%s finished', prog)
log.info('finished: %s', prog)
def main():
@ -75,12 +75,17 @@ def main():
checker = run_checker()
while True:
log.debug('checking fetcher and checker threads status')
if fetcher.isAlive() == False:
log.warning('fetcher thread is dead, respawning...')
fetcher = run_fetcher()
else:
log.debug('fetcher thread: alive')
if checker.isAlive() == False:
log.warning('checker thread is dead, respawning...')
checker = run_checker()
else:
log.debug('checker thread: alive')
# do check every 30 mins
time.sleep(1800)
@ -153,5 +158,5 @@ if not args.debug and not args.verbose:
d.gid = pw_entry[3]
d.open() # become daemon
log = get_logger(filename=log_file, log_level=log_level)
log.debug('daemonised')
log.info('started')
main()