diff --git a/docker-compose.yml b/docker-compose.yml index 0224ddf..9b95e3e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -33,12 +33,11 @@ services: ports: - "8081:80" depends_on: - data_handler: + db: condition: service_started # all the way zoomed out, with hamburg at the center, at least one camera should be returned healthcheck: - test: > - ["CMD", "curl -s 'http://localhost/camera.php?bbox=-92.52991540527346,30.683278176916133,131.7689595947266,72.87186315234298&zoom=4&width=2552&height=867' | grep '^\[.+\]$'"] + test: ["CMD", "curl", "-f", "http://localhost/sync-state.php"] interval: 10s timeout: 5s start_period: 30s diff --git a/web/www/sunders/sync-state.php b/web/www/sunders/sync-state.php index 095e92c..11ecef5 100644 --- a/web/www/sunders/sync-state.php +++ b/web/www/sunders/sync-state.php @@ -6,8 +6,9 @@ /* Connect to database */ $mysqli = new mysqli(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DB); if($mysqli->connect_errno) { + http_response_code(503); header('Content-type: application/json'); - $result = '{"error":"error while connecting to db : ' . $mysqli->error . '"}'; + $result = '{"error":"Database unavailable"}'; echo $result; exit; }