Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/zndraw/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ def daemonize(log_file: str = "zndraw.log") -> None:
# Create a new session and become session leader
os.setsid()

# Reinitialize eventlet hub after fork - kqueue file descriptors don't survive fork
import eventlet.hubs

eventlet.hubs.use_hub()

# Redirect standard file descriptors
sys.stdout.flush()
sys.stderr.flush()
Expand Down
9 changes: 5 additions & 4 deletions src/zndraw/start_celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

import os
import platform
import subprocess
import typing as t

from eventlet.green.subprocess import subprocess_orig

if t.TYPE_CHECKING:
from zndraw.config import ZnDrawConfig


def run_celery_worker(config: "ZnDrawConfig") -> subprocess.Popen:
def run_celery_worker(config: "ZnDrawConfig") -> subprocess_orig.Popen:
"""Run a celery worker with proper configuration.

Serializes the config to environment variables using the pydantic-settings
Expand All @@ -23,7 +24,7 @@ def run_celery_worker(config: "ZnDrawConfig") -> subprocess.Popen:

Returns
-------
subprocess.Popen
subprocess_orig.Popen
Running celery worker process.
"""
from zndraw.config import LMDBStorageConfig, MongoDBStorageConfig
Expand Down Expand Up @@ -79,7 +80,7 @@ def run_celery_worker(config: "ZnDrawConfig") -> subprocess.Popen:
if config.admin_password is not None:
my_env["ZNDRAW_ADMIN_PASSWORD"] = config.admin_password.get_secret_value()

worker = subprocess.Popen(
worker = subprocess_orig.Popen(
# eventlet worker - use zndraw_cli.celery for proper monkey patching
[
"celery",
Expand Down
Loading