From aa4f7c85367a91109c48c3ab4ebd86930f12553b Mon Sep 17 00:00:00 2001 From: kuaifan Date: Sat, 24 May 2025 14:39:54 +0800 Subject: [PATCH] no message --- app/Http/Controllers/IndexController.php | 9 +++++++++ docker-compose.yml | 18 ++++++++++++++++++ docker/nginx/default.conf | 2 +- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/IndexController.php b/app/Http/Controllers/IndexController.php index e542fad69..f3640d511 100755 --- a/app/Http/Controllers/IndexController.php +++ b/app/Http/Controllers/IndexController.php @@ -84,6 +84,15 @@ class IndexController extends InvokeController return Redirect::to(Base::fillUrl('api/system/version'), 301); } + /** + * 健康检查 + * @return string + */ + public function health() + { + return "ok"; + } + /** * 头像 * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response|\Symfony\Component\HttpFoundation\BinaryFileResponse diff --git a/docker-compose.yml b/docker-compose.yml index aed8e8535..b70facd0a 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,6 +22,11 @@ services: MYSQL_DB_NAME: "${DB_DATABASE}" MYSQL_USERNAME: "${DB_USERNAME}" MYSQL_PASSWORD: "${DB_PASSWORD}" + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:${LARAVELS_LISTEN_PORT}/health"] + interval: 5s + timeout: 5s + retries: 5 networks: - extnetwork depends_on: @@ -40,6 +45,14 @@ services: volumes: - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf - ./:/var/www + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost/health"] + interval: 5s + timeout: 5s + retries: 5 + depends_on: + php: + condition: service_healthy networks: - extnetwork restart: unless-stopped @@ -91,6 +104,11 @@ services: environment: HOST_PWD: "${PWD}" RUN_MODE: "strict" + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost/health"] + interval: 5s + timeout: 5s + retries: 5 networks: - extnetwork restart: unless-stopped diff --git a/docker/nginx/default.conf b/docker/nginx/default.conf index 715c444fc..140712367 100644 --- a/docker/nginx/default.conf +++ b/docker/nginx/default.conf @@ -93,7 +93,7 @@ server { proxy_set_header Server-Port $server_port; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; - proxy_pass http://appstore:8080/; + proxy_pass http://appstore/; } include /var/www/docker/appstore/config/*/nginx.conf;