HH-442: isolate runtime processes and harden shutdown (#90)

* HH-442: isolate runtime processes and harden shutdown

* HH-442: harden worker shutdown races

* HH-442: gate dependency shutdown on active handlers

---------

Co-authored-by: Rogee <rogee@ipao.vip>
This commit is contained in:
Rogee
2026-08-22 02:38:15 +08:00
committed by GitHub
co-authored by rogee
parent 6d6d80dd86
commit 798ea43c2f
35 changed files with 1673 additions and 451 deletions
+1 -1
View File
@@ -87,7 +87,7 @@ RUN mkdir -p /app/storage/uploads && chown -R gochat:gochat /app/storage
USER gochat
# Health check — references the /health endpoint we will add
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 CMD curl -f http://localhost:3000/health || exit 1
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 CMD curl -f http://localhost:3000/ready || exit 1
EXPOSE 3000
+2 -1
View File
@@ -4,12 +4,13 @@
FROM golang:1.25.13-alpine
# Install air (hot reload tool) and development tools
RUN go install github.com/air-verse/air@latest && apk add --no-cache git
RUN go install github.com/air-verse/air@v1.66.0 && apk add --no-cache git
WORKDIR /app
# Pre-download dependencies for faster rebuilds
COPY backend/go.mod backend/go.sum ./
COPY backend/internal/pgvector_stub/ ./internal/pgvector_stub/
RUN go mod download
# Full source mount via volume in compose — no COPY needed here
+3 -1
View File
@@ -48,6 +48,7 @@ services:
context: ../..
dockerfile: deploy/docker/Dockerfile.dev
container_name: gochat-app
stop_grace_period: 30s
depends_on:
postgres:
condition: service_healthy
@@ -70,12 +71,13 @@ services:
context: ../..
dockerfile: deploy/docker/Dockerfile.dev
container_name: gochat-worker
stop_grace_period: 30s
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
command: ["serve", "--worker-only"]
command: ["go", "run", "./cmd/gochat", "worker"]
volumes:
- ../../backend:/app
env_file: ../../.env
+6 -2
View File
@@ -77,6 +77,7 @@ services:
gochat:
image: *gochat-image
restart: always
stop_grace_period: ${GOCHAT_STOP_GRACE_PERIOD:-35s}
depends_on:
postgres:
condition: service_healthy
@@ -90,7 +91,7 @@ services:
volumes:
- gochat_storage:/app/storage
healthcheck:
test: ["CMD", "curl", "-fsS", "http://127.0.0.1:3000/health"]
test: ["CMD", "curl", "-fsS", "http://127.0.0.1:3000/ready"]
interval: 10s
timeout: 5s
start_period: 15s
@@ -107,14 +108,17 @@ services:
worker:
image: *gochat-image
restart: always
stop_grace_period: ${GOCHAT_STOP_GRACE_PERIOD:-35s}
depends_on:
gochat:
condition: service_healthy
postgres:
condition: service_healthy
redis:
condition: service_healthy
meilisearch:
condition: service_healthy
command: ["serve", "--worker-only"]
command: ["worker"]
environment:
<<: *gochat-environment
GOCHAT_DATABASE_RUN_MIGRATIONS: "false"
+22
View File
@@ -48,6 +48,7 @@ services:
context: ../..
dockerfile: deploy/docker/Dockerfile
container_name: gochat-app
stop_grace_period: 30s
depends_on:
postgres:
condition: service_healthy
@@ -63,6 +64,27 @@ services:
volumes:
- ../../backend:/app:delegated
worker:
build:
context: ../..
dockerfile: deploy/docker/Dockerfile
container_name: gochat-worker
stop_grace_period: 30s
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
env_file: ../../.env
environment:
- GOCHAT_ENV=development
- GOCHAT_DATABASE_DSN=postgres://postgres:postgres@postgres:5432/gochat_dev?sslmode=disable
- GOCHAT_DATABASE_RUN_MIGRATIONS=false
- GOCHAT_REDIS_DSN=redis://redis:6379
volumes:
- ../../backend:/app:delegated
command: ["worker"]
volumes:
postgres_data:
redis_data: