Add endpoint to restart Frigate (#8440)

* 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.

* Add new section to API docs

* Remove extra line
This commit is contained in:
coperni 2023-11-03 22:19:29 -04:00 committed by GitHub
parent ef750e73a2
commit ac53993f70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 0 deletions

View File

@ -365,3 +365,7 @@ Recording retention config still applies to manual events, if frigate is configu
### `PUT /api/events/<event_id>/end` ### `PUT /api/events/<event_id>/end`
End a specific manual event without a predetermined length. End a specific manual event without a predetermined length.
### `POST /api/restart`
Restarts Frigate process.

View File

@ -2103,3 +2103,30 @@ def logs(service: str):
jsonify({"success": False, "message": "Could not find log file"}), jsonify({"success": False, "message": "Could not find log file"}),
500, 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,
)