Skip to content

Conversation

@stbenjam
Copy link

@stbenjam stbenjam commented Oct 8, 2025

Fixes #103

Use exec in docker-entrypoint.sh to replace the shell process with
the Python process, making it PID 1. This ensures SIGTERM and SIGINT
signals are properly received and handled during shutdown, preventing
the container from hanging indefinitely when stopped.

Without exec, the shell script remains as PID 1 and doesn't forward
signals to the child Python process, causing it to wait forever for
stdin to close in stdio mode.

Reproducer:

$DOCKER run -p 8000:8000 -e DATABASE_URI -access-mode=restricted --transport=sse

Without these changes, ^C does not work and the process is hung
forever. After these changes ^C properly exits.

Also fixes to build the postgres container, the app user doesn't seem to exist in the base image.

Use exec in docker-entrypoint.sh to replace the shell process with
the Python process, making it PID 1. This ensures SIGTERM and SIGINT
signals are properly received and handled during shutdown, preventing
the container from hanging indefinitely when stopped.

Without exec, the shell script remains as PID 1 and doesn't forward
signals to the child Python process, causing it to wait forever for
stdin to close in stdio mode.

Reproducer:

```
$DOCKER run -p 8000:8000 -e DATABASE_URI -access-mode=restricted --transport=sse
```

Without these changes, `^C` does not work and the process is hung
forever.  After these changes `^C` properly exits.

Assisted-by: Cursor AI
I'm not able to build the Dockerfile as the `app` user doesn't exist in
the base image.  This creates it.

It also makes sure the app runs as non-root.
surajmandalcell referenced this pull request in surajmandalcell/pgsql-mcp Dec 14, 2025
This commit addresses the following issues:

- #118: Add percentile_cont, percentile_disc, mode to ALLOWED_FUNCTIONS
- #111: Fix PostgreSQL ≤12 compatibility for stddev_exec_time column
- #110: Fix Docker entrypoint (add exec) and create app user in Dockerfile
- #109 & #94: Fix double quote parsing and sequence name escaping
- #99: Add configurable query timeout via QUERY_TIMEOUT env var or --query-timeout
- #95: Redirect logging to stderr to avoid interfering with stdio MCP transport
- #93: Update broken README links to archived MCP servers repo
- #100 & #74: Add uvx and WSL instructions to README
- #71: Add table/column comments to metadata tools (list_objects, get_object_details)

Changes:
- safe_sql.py: Add ordered-set aggregate functions
- top_queries_calc.py: Use version-appropriate column name for stddev
- docker-entrypoint.sh: Use exec for proper signal handling
- Dockerfile: Create app user before COPY with --chown
- sequence_health_calc.py: Fix parsing of quoted identifiers
- server.py: Add configurable timeout, table/column comments in metadata
- __init__.py: Configure logging to stderr
- README.md: Add uvx/WSL instructions, fix broken links
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docker spins up a large number of containers

1 participant