Skip to content

Commit 3ac519e

Browse files
committed
Remove pidfile feature from server
Modern process managers (systemd, Docker) track PIDs themselves. This was inherited gunicorn code for Type=forking systemd units, but Plain's arbiter runs in the foreground where the PID is already known to the supervisor.
1 parent b48cdba commit 3ac519e

File tree

5 files changed

+1
-107
lines changed

5 files changed

+1
-107
lines changed

plain/plain/cli/server.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,6 @@
5959
setting="SERVER_ACCESS_LOG",
6060
help="Enable/disable access logging to stdout",
6161
)
62-
@click.option(
63-
"--pidfile",
64-
type=click.Path(),
65-
help="PID file path",
66-
)
6762
def server(
6863
bind: tuple[str, ...],
6964
threads: int,
@@ -73,7 +68,6 @@ def server(
7368
keyfile: str | None,
7469
reload: bool,
7570
access_log: bool,
76-
pidfile: str | None,
7771
) -> None:
7872
"""Production-ready HTTP server"""
7973
from plain.runtime import settings
@@ -98,7 +92,6 @@ def server(
9892
workers=workers,
9993
timeout=timeout,
10094
reload=reload,
101-
pidfile=pidfile,
10295
certfile=certfile,
10396
keyfile=keyfile,
10497
accesslog=access_log,

plain/plain/server/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ Most options can also be configured via settings (see below). CLI arguments take
6969
| `--reload` | - | Restart workers on code changes |
7070
| `--certfile` | - | Path to SSL certificate file |
7171
| `--keyfile` | - | Path to SSL key file |
72-
| `--pidfile` | - | PID file path |
7372

7473
## Settings
7574

plain/plain/server/app.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ def __init__(
2525
threads: int,
2626
timeout: int,
2727
reload: bool,
28-
pidfile: str | None,
2928
certfile: str | None,
3029
keyfile: str | None,
3130
accesslog: bool,
@@ -35,7 +34,6 @@ def __init__(
3534
self.threads = threads
3635
self.timeout = timeout
3736
self.reload = reload
38-
self.pidfile = pidfile
3937
self.certfile = certfile
4038
self.keyfile = keyfile
4139
self.accesslog = accesslog

plain/plain/server/arbiter.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
from . import sock
2424
from .errors import APP_LOAD_ERROR, WORKER_BOOT_ERROR, HaltServer
25-
from .pidfile import Pidfile
2625
from .workers.entry import worker_main
2726
from .workers.thread import check_worker_config
2827
from .workers.workertmp import WorkerHeartbeat
@@ -55,8 +54,6 @@ def __init__(self, app: ServerApplication):
5554
self.timeout: int = app.timeout
5655
self.pid: int = os.getpid()
5756
self.worker_age: int = 0
58-
self.pidfile: Pidfile | None = None
59-
6057
self._workers: dict[int, WorkerInfo] = {}
6158
self._listeners: list[sock.BaseSocket] = []
6259
self._shutdown_event = threading.Event()
@@ -90,16 +87,10 @@ def run(self) -> None:
9087
except Exception:
9188
self.log.error("Unhandled exception in main loop", exc_info=True)
9289
self._stop(graceful=False)
93-
if self.pidfile is not None:
94-
self.pidfile.unlink()
9590
sys.exit(-1)
9691

9792
def _start(self) -> None:
98-
"""Initialize the arbiter. Start listening and set pidfile if needed."""
99-
if self.app.pidfile is not None:
100-
self.pidfile = Pidfile(self.app.pidfile)
101-
self.pidfile.create(self.pid)
102-
93+
"""Initialize the arbiter. Start listening."""
10394
# SIGTERM = graceful shutdown, SIGINT/SIGQUIT = immediate shutdown
10495
signal.signal(signal.SIGTERM, self._handle_signal)
10596
signal.signal(signal.SIGINT, self._handle_hard_stop)
@@ -135,8 +126,6 @@ def _halt(
135126
if reason is not None:
136127
log_func("Reason: %s", reason)
137128

138-
if self.pidfile is not None:
139-
self.pidfile.unlink()
140129
sys.exit(exit_status)
141130

142131
def _stop(self, graceful: bool = True) -> None:

plain/plain/server/pidfile.py

Lines changed: 0 additions & 85 deletions
This file was deleted.

0 commit comments

Comments
 (0)