cloudron-support: add --check-cloudron-services and add it to troubleshoot
This commit is contained in:
committed by
Girish Ramakrishnan
parent
4bf0dc192c
commit
e0367056bd
@@ -33,6 +33,7 @@ readonly HELP_MESSAGE="
|
||||
--send-diagnostics Collects server diagnostics and uploads it to ${PASTEBIN}
|
||||
--check-db-migration Checks if the DB migrations are up to date.
|
||||
--apply-db-migration Applys all pending DB migrations.
|
||||
--check-cloudron-services Checks if all Cloudron services are running and healthy.
|
||||
--troubleshoot Dashboard down? Run tests to identify the potential problem
|
||||
--unbound-use-external-dns Forwards all Unbound requests to Google (8.8.8.8) and Cloudflare (1.1.1.1) DNS servers.
|
||||
Unbound is the internal DNS server used for recursive DNS queries. This is only needed
|
||||
@@ -643,6 +644,7 @@ function troubleshoot() {
|
||||
check_expired_domain
|
||||
check_unbound # this is less fatal after 8.0
|
||||
check_db_migration
|
||||
check_cloudron_services
|
||||
}
|
||||
|
||||
function cleanup_disk_space() {
|
||||
@@ -863,9 +865,45 @@ function apply_db_migration() {
|
||||
bash /home/yellowtent/box/setup/start.sh && success "Database migrations applied successfully" || fail "Database migrations failed"
|
||||
}
|
||||
|
||||
function check_cloudron_services() {
|
||||
|
||||
local services=("mysql" "postgresql" "mongodb" "mail" "graphite")
|
||||
local service_ip=("172.18.30.1" "172.18.30.2" "172.18.30.3" "172.18.30.4" "172.18.30.5")
|
||||
local service_port=("3000" "3000" "3000" "3000" "2003")
|
||||
|
||||
for service in "${!services[@]}"; do
|
||||
# Check if container is running
|
||||
if [[ $(docker inspect ${services[$service]} --format={{.State.Status}}) != "running" ]]; then
|
||||
fail "${services[$service]} container is not running!"
|
||||
continue
|
||||
fi
|
||||
|
||||
# Check if service is reachable with simple nc check
|
||||
if ! nc -z -w5 ${service_ip[$service]} ${service_port[$service]} 2>/dev/null; then
|
||||
fail "${services[$service]} is not reachable"
|
||||
continue
|
||||
fi
|
||||
|
||||
# Curl the healthcheck endpoint
|
||||
if [[ ${services[$service]} != "graphite" ]]; then
|
||||
if ! grep -q "true" <<< $(curl --fail -s "http://${service_ip[$service]}:${service_port[$service]}/healthcheck"); then
|
||||
fail "${services[$service]} healthcheck failed"
|
||||
continue
|
||||
fi
|
||||
else
|
||||
# Graphite has a different healthcheck endpoint and needs to be checked differently
|
||||
if ! grep -q "Graphite Dashboard" <<< "$(curl --fail -s http://${service_ip[$service]}:8000/graphite-web/dashboard)"; then
|
||||
fail "${services[$service]} healthcheck failed"
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
success "${services[$service]} is running and healthy"
|
||||
done
|
||||
}
|
||||
|
||||
check_disk_space
|
||||
|
||||
args=$(getopt -o "" -l "admin-login,disable-dnssec,enable-remote-support,disable-remote-support,help,owner-login,patch:,recreate-containers,recreate-docker,fix-docker-version,send-diagnostics,unbound-use-external-dns,troubleshoot,check-db-migration,apply-db-migration" -n "$0" -- "$@")
|
||||
args=$(getopt -o "" -l "admin-login,disable-dnssec,enable-remote-support,disable-remote-support,help,owner-login,patch:,recreate-containers,recreate-docker,fix-docker-version,send-diagnostics,unbound-use-external-dns,troubleshoot,check-db-migration,apply-db-migration,check-cloudron-services" -n "$0" -- "$@")
|
||||
eval set -- "${args}"
|
||||
|
||||
while true; do
|
||||
@@ -888,6 +926,7 @@ while true; do
|
||||
--fix-docker-version) fix_docker_version; exit 0;;
|
||||
--check-db-migration) check_db_migration; exit 0;;
|
||||
--apply-db-migration) apply_db_migration; exit 0;;
|
||||
--check-cloudron-services) check_cloudron_services; exit 0;;
|
||||
--patch) apply_patch "$2"; exit 0;;
|
||||
--help) break;;
|
||||
--) break;;
|
||||
|
||||
Reference in New Issue
Block a user