Conversation
unlink() on /run/nginx.pid fails with Permission Denied because /run/ is root-owned. Moving the PID file to /home/packmind/nginx.pid resolves the 119 weekly alerts on pod graceful shutdown. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
Greptile SummaryThis PR fixes a permission error on graceful nginx shutdown by relocating the PID file from Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Container Start] --> B[nginx-entrypoint.sh]
B --> C{NGINX_ENV?}
C -- K8S + no ingress --> D[envsubst renders\nnginx.k8s.no-ingress.conf\nto /tmp/nginx.conf]
C -- K8S + ingress --> E[nginx -c nginx.k8s.conf]
C -- compose --> F[nginx -c nginx.compose.conf]
D --> G[nginx -c /tmp/nginx.conf]
E --> H[Write PID to\n/home/packmind/nginx.pid]
F --> H
G --> H
H --> I[nginx running as packmind:1000]
I --> J{SIGQUIT received}
J --> K[nginx calls unlink\non /home/packmind/nginx.pid]
K --> L[packmind owns /home/packmind ✓\nunlink succeeds]
L --> M[Clean shutdown]
style L fill:#90EE90
style K fill:#90EE90
Reviews (1): Last reviewed commit: "🐛 fix(nginx): move PID file to writable..." | Re-trigger Greptile |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Explanation
Move the nginx PID file from
/run/nginx.pidto/home/packmind/nginx.pidto fixPermission Deniederrors on graceful shutdown.On pod shutdown (SIGQUIT), nginx calls
unlink()on the PID file, which requires write permission on the parent directory./run/is root-owned, so the call fails even though the file itself is owned bypackmind. Moving to/home/packmind/(already owned bypackmind) resolves this.Impact: eliminates ~119
[alert] unlink() "/run/nginx.pid" failed (13: Permission denied)log entries per week.Type of Change
Affected Components
Testing
Test Details:
/home/packmind/nginx.pidunlinkpermission error in logsTODO List
Reviewer Notes
Pure config change across 4 files — no code logic modified. The recursive
chown ... /home/packmindin the Dockerfile already covers the new PID file location, so/run/nginx.pidwas removed from the explicitchownlist.🤖 Generated with Claude Code