nautobot / nautobot-lab

All-in-one Docker container that allows a user to explore Nautobot in a lab environment.
Apache License 2.0
41 stars 13 forks source link

Add Supervisord Healthcheck #14

Closed jtdub closed 3 years ago

jtdub commented 3 years ago

This fixes #2 by using supervisorctl to monitor the status of the Nautobot app, Nautobot Worker, Redis, and Postgresql.

This is what is looks like when all services, managed by supervisord are running:

root@ea8e263f703b:/opt/nautobot# supervisorctl status || exit 1
nautobot                         RUNNING   pid 9, uptime 0:04:29
nautobot-worker                  RUNNING   pid 10, uptime 0:04:29
postgresql-server                RUNNING   pid 11, uptime 0:04:29
redis-server                     RUNNING   pid 12, uptime 0:04:29

This is what it looks like when you stop a service and recheck.

root@ea8e263f703b:/opt/nautobot# supervisorctl stop redis-server
redis-server: stopped
root@ea8e263f703b:/opt/nautobot# supervisorctl status || exit 1
nautobot                         RUNNING   pid 9, uptime 0:05:34
nautobot-worker                  BACKOFF   Exited too quickly (process log may have details)
postgresql-server                RUNNING   pid 11, uptime 0:05:34
redis-server                     STOPPED   Mar 08 08:58 AM
exit

The || exit 1 will exit upon a exit status of 1. This informs the Docker Healthcheck that the container is in an unhealthy state.