if not website.db: # Re-exec in 30 second to see if the DB is back up if 'gunicorn' in sys.modules: # SIGTERM is used to tell gunicorn to gracefully stop the worker # http://docs.gunicorn.org/en/stable/signals.html Timer(30.0, lambda: os.kill(os.getpid(), signal.SIGTERM)).start() else: # SIGUSR1 is used to tell apache to gracefully restart this worker # https://httpd.apache.org/docs/current/stopping.html Timer(30.0, lambda: os.kill(os.getpid(), signal.SIGUSR1)).start() if env.cache_static: http_caching.compile_assets(website) website.request_processor.dispatcher.build_dispatch_tree() elif env.clean_assets: http_caching.clean_assets(website.www_root) website.request_processor.dispatcher.build_dispatch_tree() # Periodic jobs # ============= conf = website.app_conf if conf: intervals = conf.cron_intervals cron = Cron(website) cron(intervals.get('check_db', 600), website.db.self_check, True) cron(intervals.get('dequeue_emails', 60), Participant.dequeue_emails, True) cron(intervals.get('send_newsletters', 60), Participant.send_newsletters, True) cron(intervals.get('refetch_elsewhere_data', 120), refetch_elsewhere_data, True)
if not website.db: # Re-exec in 30 second to see if the DB is back up if 'gunicorn' in sys.modules: # SIGTERM is used to tell gunicorn to gracefully stop the worker # http://docs.gunicorn.org/en/stable/signals.html Timer(30.0, lambda: os.kill(os.getpid(), signal.SIGTERM)).start() else: # SIGUSR1 is used to tell apache to gracefully restart this worker # https://httpd.apache.org/docs/current/stopping.html Timer(30.0, lambda: os.kill(os.getpid(), signal.SIGUSR1)).start() if env.cache_static: http_caching.compile_assets(website) elif env.clean_assets: http_caching.clean_assets(website.www_root) # Periodic jobs # ============= conf = website.app_conf if conf: intervals = conf.cron_intervals cron = Cron(website) cron(intervals.get('check_db', 600), website.db.self_check, True) cron(intervals.get('dequeue_emails', 60), Participant.dequeue_emails, True) cron(intervals.get('send_newsletters', 60), Participant.send_newsletters, True) cron(intervals.get('refetch_elsewhere_data', 120), refetch_elsewhere_data, True) cron(intervals.get('refetch_repos', 60), refetch_repos, True) cron(Weekly(weekday=3, hour=2), create_payday_issue, True)