Improve worker start/stop logging messages (#1105)

main
Selwin Ong 6 years ago committed by GitHub
parent e1c135d4de
commit 905824e8d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -448,7 +448,7 @@ class Worker(object):
self._install_signal_handlers() self._install_signal_handlers()
completed_jobs = 0 completed_jobs = 0
self.register_birth() self.register_birth()
self.log.info("RQ worker %r started, version %s", self.key, VERSION) self.log.info("Worker %s: started, version %s", self.key, VERSION)
self.set_state(WorkerStatus.STARTED) self.set_state(WorkerStatus.STARTED)
qnames = self.queue_names() qnames = self.queue_names()
self.log.info('*** Listening on %s...', green(', '.join(qnames))) self.log.info('*** Listening on %s...', green(', '.join(qnames)))
@ -462,7 +462,7 @@ class Worker(object):
self.clean_registries() self.clean_registries()
if self._stop_requested: if self._stop_requested:
self.log.info('Stopping on request') self.log.info('Worker %s: stopping on request', self.key)
break break
timeout = None if burst else max(1, self.default_worker_ttl - 15) timeout = None if burst else max(1, self.default_worker_ttl - 15)
@ -470,7 +470,7 @@ class Worker(object):
result = self.dequeue_job_and_maintain_ttl(timeout) result = self.dequeue_job_and_maintain_ttl(timeout)
if result is None: if result is None:
if burst: if burst:
self.log.info("RQ worker %r done, quitting", self.key) self.log.info("Worker %s: done, quitting", self.key)
break break
job, queue = result job, queue = result
@ -481,7 +481,7 @@ class Worker(object):
if max_jobs is not None: if max_jobs is not None:
if completed_jobs >= max_jobs: if completed_jobs >= max_jobs:
self.log.info( self.log.info(
"RQ Worker %r finished executing %d jobs, quitting", "Worker %s: finished executing %d jobs, quitting",
self.key, completed_jobs self.key, completed_jobs
) )
break break
@ -495,7 +495,7 @@ class Worker(object):
except: # noqa except: # noqa
self.log.error( self.log.error(
'RQ Worker %r: found an unhandled exception, quitting...', 'Worker %s: found an unhandled exception, quitting...',
self.key, exc_info=True self.key, exc_info=True
) )
break break
@ -527,7 +527,7 @@ class Worker(object):
'%s: %s (%s)', green(queue.name), '%s: %s (%s)', green(queue.name),
blue(job.description), job.id) blue(job.description), job.id)
else: else:
self.log.info('%s:%s', green(queue.name), job.id) self.log.info('%s: %s', green(queue.name), job.id)
break break
except DequeueTimeout: except DequeueTimeout:
@ -965,7 +965,10 @@ class HerokuWorker(Worker):
def handle_warm_shutdown_request(self): def handle_warm_shutdown_request(self):
"""If horse is alive send it SIGRTMIN""" """If horse is alive send it SIGRTMIN"""
if self.horse_pid != 0: if self.horse_pid != 0:
self.log.info('Warm shut down requested, sending horse SIGRTMIN signal') self.log.info(
'Worker %s: warm shut down requested, sending horse SIGRTMIN signal',
self.key
)
self.kill_horse(sig=signal.SIGRTMIN) self.kill_horse(sig=signal.SIGRTMIN)
else: else:
self.log.warning('Warm shut down requested, no horse found') self.log.warning('Warm shut down requested, no horse found')

Loading…
Cancel
Save