41 lines
982 B
Python
41 lines
982 B
Python
import time
|
|
|
|
import flask
|
|
|
|
import config
|
|
import biz.task
|
|
import template
|
|
from telemetry import init_opentelemetry
|
|
from template import load_local_template
|
|
from util import api
|
|
|
|
load_local_template()
|
|
import logging
|
|
|
|
LOGGER = logging.getLogger(__name__)
|
|
init_opentelemetry(batch=False)
|
|
app = flask.Flask(__name__)
|
|
|
|
@app.get('/health/check')
|
|
def health_check():
|
|
return api.sync_center()
|
|
|
|
@app.post('/')
|
|
def do_nothing():
|
|
return "NOOP"
|
|
|
|
@app.post('/<task_id>')
|
|
def do_task(task_id):
|
|
task_info = api.get_task_info(task_id)
|
|
local_template_info = template.get_template_def(task_info.get("templateId"))
|
|
template_info = api.get_template_info(task_info.get("templateId"))
|
|
if local_template_info:
|
|
if local_template_info.get("updateTime") != template_info.get("updateTime"):
|
|
template.download_template(task_info.get("templateId"))
|
|
biz.task.start_task(task_info)
|
|
return "OK"
|
|
|
|
|
|
if __name__ == '__main__':
|
|
app.run(host="0.0.0.0", port=9998)
|