2020-06-10 12:18:02 +00:00
|
|
|
from logger.logger import init_logger
|
2020-06-05 12:42:04 +00:00
|
|
|
from tasks.check_corpora import check_corpora
|
2020-06-08 08:23:32 +00:00
|
|
|
from tasks.check_jobs import check_jobs
|
2020-06-05 12:42:04 +00:00
|
|
|
from tasks.notify import notify
|
2020-06-10 12:18:02 +00:00
|
|
|
from time import sleep
|
2020-06-08 11:52:54 +00:00
|
|
|
import os
|
2020-06-05 12:42:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
def nopaqued():
|
2020-06-10 12:18:02 +00:00
|
|
|
logger = init_logger()
|
|
|
|
NOPAQUE_EXECUTE_NOTIFICATIONS = os.environ.get('NOPAQUE_EXECUTE_NOTIFICATIONS', 'True').lower() == 'true' # noqa
|
|
|
|
threads = {'check_corpora': None, 'check_jobs': None, 'notify': None}
|
|
|
|
|
|
|
|
threads['check_corpora'] = check_corpora()
|
|
|
|
threads['check_jobs'] = check_jobs()
|
|
|
|
threads['notify'] = notify(NOPAQUE_EXECUTE_NOTIFICATIONS)
|
2020-06-05 12:42:04 +00:00
|
|
|
while True:
|
2020-06-10 12:18:02 +00:00
|
|
|
logger.warning('check_corpora: {}'.format(threads['check_corpora'].is_alive()))
|
|
|
|
if not threads['check_corpora'].is_alive():
|
|
|
|
threads['check_corpora'] = check_corpora()
|
|
|
|
logger.warning('check_jobs: {}'.format(threads['check_jobs'].is_alive()))
|
|
|
|
if not threads['check_jobs'].is_alive():
|
|
|
|
threads['check_jobs'] = check_jobs()
|
|
|
|
logger.warning('notify: {}'.format(threads['notify'].is_alive()))
|
|
|
|
if not threads['notify'].is_alive():
|
|
|
|
threads['notify'] = notify(NOPAQUE_EXECUTE_NOTIFICATIONS)
|
2020-06-08 11:52:54 +00:00
|
|
|
# If execute_notifications True mails are sent.
|
|
|
|
# If execute_notifications False no mails are sent.
|
2020-06-08 08:23:32 +00:00
|
|
|
# But notification status will be set nonetheless.
|
2020-06-10 12:18:02 +00:00
|
|
|
sleep(3)
|
2020-06-05 12:42:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
nopaqued()
|