添加运行状态上报机制

This commit is contained in:
pengtao 2019-09-29 13:11:53 +08:00
parent 4a62f9a8f0
commit cf70f5ea89

View File

@ -64,6 +64,7 @@ def sadd_adkey(key, line):
def produce_task():
# log.info("start produce cache !")
now = datetime.datetime.today().strftime("%Y-%m-%d %H:%M:%S")
run_status = 1
all = []
get_data_sql = f"""select
id,
@ -116,6 +117,7 @@ def produce_task():
item['ad_property'].update(temp)
item['ad_property'] = json.dumps(item['ad_property'])
except Exception:
run_status = 0
log.error(f"write {item}", exc_info=True)
all.append(item)
except Exception:
@ -154,4 +156,9 @@ def produce_task():
log.error(f"get ad_num from mysql failed! ad_num={line['ad_num']}")
except Exception:
log.error(f"split {line} failed!", exc_info=True)
run_status = 0
log.info(f"produce {len(all)} 2 redis!") #log.info("end produce cache!")
my_redis.set("ad_produce", run_status)
now = datetime.datetime.now()
timestamp = datetime.datetime.timestamp(now)
my_redis.set("ad_produce_time", timestamp)