Run the dirty arbiter (blocking call).
(self)
| 232 | self.app_worker_map[app_path].discard(worker_pid) |
| 233 | |
| 234 | def run(self): |
| 235 | """Run the dirty arbiter (blocking call).""" |
| 236 | self.pid = os.getpid() |
| 237 | self.log.info("Dirty arbiter starting (pid: %s)", self.pid) |
| 238 | |
| 239 | # Write PID to well-known location for orphan detection |
| 240 | if self.pidfile: |
| 241 | try: |
| 242 | with open(self.pidfile, 'w') as f: |
| 243 | f.write(str(self.pid)) |
| 244 | except IOError as e: |
| 245 | self.log.warning("Failed to write PID file: %s", e) |
| 246 | |
| 247 | # Set socket path env var for dirty workers (enables stash access) |
| 248 | os.environ['GUNICORN_DIRTY_SOCKET'] = self.socket_path |
| 249 | |
| 250 | # Call hook |
| 251 | self.cfg.on_dirty_starting(self) |
| 252 | |
| 253 | # Set up signal handlers |
| 254 | self.init_signals() |
| 255 | |
| 256 | # Set process title |
| 257 | util._setproctitle("dirty-arbiter") |
| 258 | |
| 259 | try: |
| 260 | asyncio.run(self._run_async()) |
| 261 | except KeyboardInterrupt: |
| 262 | pass |
| 263 | finally: |
| 264 | self._cleanup_sync() |
| 265 | |
| 266 | def init_signals(self): |
| 267 | """Set up signal handlers.""" |