diff --git a/beat/web/scripts/process.py b/beat/web/scripts/process.py index 4f4e6eb9914cd079d61c1edc36238631a8dd8bd6..cb3ab9783b9e7d037a60f2cf4a9699ea040a7d66 100644 --- a/beat/web/scripts/process.py +++ b/beat/web/scripts/process.py @@ -88,7 +88,7 @@ def main(user_input=None): from django import setup setup() - logger = logging.getLogger('beat.web') + logger = logging.getLogger(__name__) if arguments['--verbose'] == 1: logger.setLevel(logging.INFO) elif arguments['--verbose'] >= 2: logger.setLevel(logging.DEBUG) diff --git a/beat/web/scripts/scheduler.py b/beat/web/scripts/scheduler.py index 3db13dd2a534987a845f9f6f91410318a1c2516f..d21b28cc1dd8782d3c8431fa9aefc2298cadc2c3 100644 --- a/beat/web/scripts/scheduler.py +++ b/beat/web/scripts/scheduler.py @@ -83,7 +83,7 @@ def main(user_input=None): from django import setup setup() - logger = logging.getLogger('beat.web') + logger = logging.getLogger(__name__) if arguments['--verbose'] == 1: logger.setLevel(logging.INFO) elif arguments['--verbose'] >= 2: logger.setLevel(logging.DEBUG) @@ -104,15 +104,12 @@ def main(user_input=None): global stop while not stop: - try: - start = time.time() - logger.debug("Starting scheduling cycle...") - schedule.send_experiment_emails() - schedule.schedule() - duration = time.time() - start - if duration < timing: - time.sleep(timing - duration) - - except KeyboardInterrupt: - logger.info("CTRL-c caught, terminating...") - stop = True + start = time.time() + logger.debug("Starting scheduler cycle...") + schedule.send_experiment_emails() + schedule.schedule() + duration = time.time() - start + if duration < timing: + time.sleep(timing - duration) + + logger.info("Gracefully exiting the scheduler") diff --git a/beat/web/scripts/worker.py b/beat/web/scripts/worker.py index 39c2c209f7aa5699cf1c9a558cb0f8774b9642d9..8127c2cc218352200d5c7ab97ac5fb46709e8fd1 100644 --- a/beat/web/scripts/worker.py +++ b/beat/web/scripts/worker.py @@ -95,7 +95,7 @@ def main(user_input=None): from django import setup setup() - logger = logging.getLogger('beat.web') + logger = logging.getLogger(__name__) if arguments['--verbose'] == 1: logger.setLevel(logging.INFO) elif arguments['--verbose'] >= 2: logger.setLevel(logging.DEBUG) @@ -113,27 +113,23 @@ def main(user_input=None): from beat.core.async import resolve_cpulimit_path cpulimit = resolve_cpulimit_path(arguments['--cpulimit']) process = utils.resolve_process_path() - environments = utils.find_environments(arguments['--environments'] or []) + environments = utils.find_environments(arguments['--environments']) timing = int(arguments['--period']) \ if arguments['--period'] else settings.WORKER_INTERVAL - logger.info("Working every %d seconds", timing) + logger.info("Working at `%s' every %d seconds", arguments['--name'], timing) global stop with Worker.objects.get(name=arguments['--name']) as worker: while not stop: - try: + start = time.time() + logger.debug("Starting work cycle...") + utils.cleanup_zombies() + worker.work(environments, cpulimit, process) + duration = time.time() - start + if duration < timing: + time.sleep(timing - duration) - start = time.time() - logger.debug("Starting work cycle...") - utils.cleanup_zombies() - worker.work(environments, cpulimit, process) - duration = time.time() - start - if duration < timing: - time.sleep(timing - duration) - - except KeyboardInterrupt: - logger.info("CTRL-c caught, terminating...") - stop = True + logger.info("Gracefully exiting worker `%s'" % arguments['--name'])