Skip to content

Commit 5e7931f

Browse files
authored
Merge pull request #4 from utensils/develop
fix(docker): ensure container exits instantly without hanging
2 parents 5b0ae2e + 44fa188 commit 5e7931f

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

Dockerfile

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,21 @@ RUN pip install --no-cache-dir -e .
1717
RUN echo "Running pre-cache to populate cache data..." && \
1818
python -m mcp_nixos --pre-cache
1919

20-
# Run the MCP server
21-
CMD ["python", "-m", "mcp_nixos"]
20+
# Set environment variables to ensure clean exit
21+
ENV PYTHONUNBUFFERED=1
22+
ENV MCP_NIXOS_CLEANUP_ORPHANS=true
23+
# Set low timeout values for all operations
24+
ENV MCP_NIXOS_SHUTDOWN_TIMEOUT=0.1
25+
ENV MCP_NIXOS_STARTUP_TIMEOUT=1.0
26+
27+
# Use tini as init system to handle signals properly
28+
RUN apt-get update && apt-get install -y tini && rm -rf /var/lib/apt/lists/*
29+
30+
# Use tini as entrypoint for proper signal forwarding and zombie reaping
31+
ENTRYPOINT ["/usr/bin/tini", "--"]
32+
33+
# Run the MCP server through the run.py wrapper for better termination handling
34+
CMD ["python", "-m", "mcp_nixos.run"]
35+
36+
# Add signal handler to ensure container exits cleanly
37+
STOPSIGNAL SIGTERM

0 commit comments

Comments
 (0)