Debug jobs
This commit is contained in:
@@ -24,3 +24,15 @@ curl -X POST "https://smartwave.matthiasg.dev/alert" \
|
|||||||
"logs": []
|
"logs": []
|
||||||
}'
|
}'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Jobs
|
||||||
|
|
||||||
|
### Trigger Server CVE Audit
|
||||||
|
`curl http://localhost:5000/debug/run-job/server_cve_audit_job`
|
||||||
|
|
||||||
|
### Trigger Client IP Audit
|
||||||
|
`curl http://localhost:5000/debug/run-job/client_ip_audit_job`
|
||||||
|
|
||||||
|
### Trigger Telemetry Request
|
||||||
|
`curl http://localhost:5000/debug/run-job/request_telemetry_job`
|
||||||
@@ -414,6 +414,29 @@ def debug_telemetryrequest():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
return jsonify({"error": f"Failed to publish MQTT command: {str(e)}"}), 500
|
return jsonify({"error": f"Failed to publish MQTT command: {str(e)}"}), 500
|
||||||
|
|
||||||
|
@app.route('/debug/run-job/<job_id>', methods=['POST', 'GET'])
|
||||||
|
def trigger_job_manually(job_id):
|
||||||
|
"""Manually triggers any scheduled job immediately by its ID."""
|
||||||
|
job = scheduler.get_job(job_id)
|
||||||
|
if not job:
|
||||||
|
return jsonify({
|
||||||
|
"error": f"Job '{job_id}' not found",
|
||||||
|
"available_jobs": [j.id for j in scheduler.get_jobs()]
|
||||||
|
}), 404
|
||||||
|
|
||||||
|
# Execute the underlying function with its configured arguments
|
||||||
|
try:
|
||||||
|
job.func(*job.args)
|
||||||
|
return jsonify({
|
||||||
|
"status": "success",
|
||||||
|
"message": f"Job '{job_id}' executed successfully."
|
||||||
|
}), 200
|
||||||
|
except Exception as e:
|
||||||
|
return jsonify({
|
||||||
|
"status": "error",
|
||||||
|
"message": f"Job execution failed: {str(e)}"
|
||||||
|
}), 500
|
||||||
|
|
||||||
@app.route("/debug", methods=["GET"])
|
@app.route("/debug", methods=["GET"])
|
||||||
def debug():
|
def debug():
|
||||||
return safety_checker.check_dish_safety(os.path.join(CAMERA_IMAGE_DIR, "dish_0de0ee1dab8949fc8e78796947e24ed3.jpg"))
|
return safety_checker.check_dish_safety(os.path.join(CAMERA_IMAGE_DIR, "dish_0de0ee1dab8949fc8e78796947e24ed3.jpg"))
|
||||||
|
|||||||
Reference in New Issue
Block a user