Skip to content

Conversation

mengxunQAQ
Copy link

  • Many software also have a pidfile, eg NGINX., but it does not exit just because the process number in the pidfile is running; it merely writes a new pid to the file
  • Whether to run repeatedly or not can be guaranteed by the user themselves

…id is running

Signed-off-by: mengxun <mengxun1122@163.com>
@pajod
Copy link
Contributor

pajod commented Jun 17, 2025

The user can also guarantee to not place the PIDfile on persistent storage. This could be a documentation change only, while keeping the helpful (and, except in cases of rare pid recycling, generally the result of a clear mistake) error.

Side note: Anyone not interested in the old behavior is probably better served by running an init that remembers what processes it started (such as systemd) and never care about pid files ever again.

@benoitc
Copy link
Owner

benoitc commented Aug 3, 2025

I don't understand what this issue is about. Please clarify the context when this jhappen. and when/what to reproduce.

@mengxunQAQ
Copy link
Author

mengxunQAQ commented Aug 4, 2025

I don't understand what this issue is about. Please clarify the context when this jhappen. and when/what to reproduce.

If the device restarts or the process is unexpectedly terminated, the PID recorded in the pid file may be taken by another process, which can prevent Gunicorn from ever starting.

In other words, the problem will occur as long as two conditions are met:

  • Gunicorn did not properly clean up the PID file.

  • During the interval when Gunicorn restarts, another process happens to use the same PID.

@mengxunQAQ
Copy link
Author

I don't understand what this issue is about. Please clarify the context when this jhappen. and when/what to reproduce.

To reproduce the issue, you can set the number in the PID file to 1, and then Gunicorn will never be able to restart.

@benoitc
Copy link
Owner

benoitc commented Oct 5, 2025

why would you do that though. Notmlally the pid file should be properly cleadned during shutdown.

@mengxunQAQ
Copy link
Author

mengxunQAQ commented Oct 9, 2025

why would you do that though. Notmlally the pid file should be properly cleadned during shutdown.

We cannot assume that a process will always receive proper termination or restart notifications.
In cases such as a device power-off, system reboot, or when the system kills the process due to high memory pressure, the process cannot be able to perform normal cleanup operations and thus fail to remove its PID file.
This can lead to conflicts.

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.

3 participants