Add endpoint to restart Frigate

The only means of restarting Frigate remotely is to issue
a restart topic on the server's websocket. It's
convenient to also expose this capability via HTTP endpoint.
This commit is contained in:
copenri 2023-11-02 23:01:28 -04:00
parent b54aaad382
commit 5cc01ca346
No known key found for this signature in database

View File

@ -2103,3 +2103,30 @@ def logs(service: str):
jsonify({"success": False, "message": "Could not find log file"}),
500,
)
@bp.route("/restart", methods=["POST"])
def restart():
try:
restart_frigate()
except Exception as e:
logging.error(f"Error restarting Frigate: {e}")
return make_response(
jsonify(
{
"success": False,
"message": "Unable to restart Frigate.",
}
),
500,
)
return make_response(
jsonify(
{
"success": True,
"message": "Restarting (this can take up to one minute)...",
}
),
200,
)