added hidden route to wake up the job manager
This commit is contained in:
28
job.py
28
job.py
@@ -47,6 +47,17 @@ def GetNumActiveJobs():
|
||||
ret = db.engine.execute("select count(1) from job where pa_job_state != 'Completed'").first()
|
||||
return ret.count
|
||||
|
||||
def WakePAJobManager():
|
||||
try:
|
||||
print("Waking up PA Job Manager")
|
||||
s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.connect((PA_JOB_MANAGER_HOST, PA_JOB_MANAGER_PORT))
|
||||
s.close()
|
||||
except Exception as e:
|
||||
st.SetAlert("danger")
|
||||
st.SetMessage("Failed to connect to job manager, has it crashed? Exception was:{}".format(e))
|
||||
return
|
||||
|
||||
###############################################################################
|
||||
# NewJob takes a name (which will be matched in pa_job_manager.py to run
|
||||
# the appropriate job - which will update the Job() until complete
|
||||
@@ -58,14 +69,7 @@ def NewJob(name, num_passes="1", num_files="0", wait_for=None ):
|
||||
db.session.add(job)
|
||||
db.session.commit()
|
||||
|
||||
try:
|
||||
print("Waking up PA Job Manager")
|
||||
s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.connect((PA_JOB_MANAGER_HOST, PA_JOB_MANAGER_PORT))
|
||||
s.close()
|
||||
except Exception as e:
|
||||
st.SetAlert("danger")
|
||||
st.SetMessage("Failed to connect to job manager, has it crashed? Exception was:{}".format(e))
|
||||
WakePAJobManager()
|
||||
return job
|
||||
|
||||
################################################################################
|
||||
@@ -93,6 +97,14 @@ def joblog(id):
|
||||
duration= duration-timedelta(microseconds=duration.microseconds)
|
||||
return render_template("joblog.html", job=joblog, logs=logs, duration=duration, page_title=page_title)
|
||||
|
||||
###############################################################################
|
||||
# /job/<id> -> GET -> shows status/history of jobs
|
||||
################################################################################
|
||||
@app.route("/wakeup", methods=["GET"])
|
||||
def wake_wrapper():
|
||||
WakePAJobManager()
|
||||
return render_template("base.html")
|
||||
|
||||
###############################################################################
|
||||
# This func creates a new filter in jinja2 to format the time from the db in a
|
||||
# way that is more readable (converted to local tz too)
|
||||
|
||||
Reference in New Issue
Block a user