Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added healthcheck endpoint /status #185

Merged
merged 1 commit into from
May 11, 2024
Merged

Added healthcheck endpoint /status #185

merged 1 commit into from
May 11, 2024

Conversation

caronc
Copy link
Owner

@caronc caronc commented Apr 21, 2024

Description:

Related issue (if applicable): refs #51

Added health check endpoint /status

Path Method Description
/status/ GET Simply returns a server status. The server http response code is a 200 if the server is working correcty and a 417 if there was an unexpected issue. You can set the Accept header to application/json or text/plain for different response outputs.

Below is a sample of just a simple text response:

# Request a general text response
# Output will read `OK` if everything is fine, otherwise it will return
# one or more of the following separated by a comma:
#  - ATTACH_PERMISSION_ISSUE: Can not write attachments (likely a permission issue)
#  - CONFIG_PERMISSION_ISSUE: Can not write configuration (likely a permission issue)
curl -X GET http://localhost:8000/status

Below is a sample of a JSON response:

curl -X GET -H "Accept: application/json" http://localhost:8000/status

The above output may look like this:

{
  "config_lock": false,
  "status": {
    "can_write_config": true,
    "can_write_attach": true,
    "details": ["OK"]
  }
}
  • The config_lock always cross references if the APPRISE_CONFIG_LOCK is enabled or not.
  • The status.can_write_config defines if the configuration directory is writable or not. If the environment variable APPRISE_STATEFUL_MODE is set to disabled, this value will always read false and it will not impact the status.details
  • The status.can_write_attach defines if the attachment directory is writable or not. If the environment variable APPRISE_ATTACH_SIZE or APPRISE_MAX_ATTACHMENTS is set to 0 (zero) or lower, this value will always read false and it will not impact the status.details.
  • The status.details identifies the overall status. If there is more then 1 issue to report here, they will all show in this list. In a working orderly environment, this will always be set to OK and the http response type will be 200.

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • No lint errors (use flake8)
  • Tests added

@caronc caronc force-pushed the healthcheck-endpoint branch 2 times, most recently from ef4693f to 87b9ba6 Compare April 23, 2024 01:55
@caronc caronc force-pushed the healthcheck-endpoint branch from 87b9ba6 to 38972a4 Compare May 11, 2024 17:29
@caronc caronc force-pushed the healthcheck-endpoint branch from 38972a4 to 47a6350 Compare May 11, 2024 18:58
@caronc caronc merged commit 135dd4e into master May 11, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant