def send_life_sign(): logger = get_task_logger(__name__) lostconfig = LOSTConfig() dbm = DBMan(lostconfig) worker = dbm.get_worker(lostconfig.worker_name) if worker is None: register_worker(dbm, lostconfig) logger.info('Registered worker: {}'.format(lostconfig.worker_name)) else: worker.timestamp = datetime.utcnow() dbm.add(worker) dbm.commit() logger.info('Sent lifesign: {}'.format(worker.worker_name)) dbm.close_session()
def init_worker_on_startup(): lostconfig = LOSTConfig() dbm = DBMan(lostconfig) worker = dbm.get_worker(lostconfig.worker_name) if worker is None: register_worker(dbm, lostconfig) print('Registered worker: {}'.format(lostconfig.worker_name)) else: worker.timestamp = datetime.utcnow() worker.resources = '[]' worker.in_progress = '{}' dbm.add(worker) dbm.commit() print('Reset worker on startup: {}'.format(worker.worker_name)) dbm.close_session()