-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(daemon): allows daemonization options to be fetched from app set…
…tings (#8553) * feat(daemon): allows daemonization options to be fetched from app settings * Update docs/userguide/configuration.rst Co-authored-by: Omer Katz <omer.katz@kcg.tech> * Update docs/userguide/configuration.rst Co-authored-by: Omer Katz <omer.katz@kcg.tech> * Update docs/userguide/configuration.rst Co-authored-by: Omer Katz <omer.katz@kcg.tech> * Update docs/userguide/configuration.rst Co-authored-by: Omer Katz <omer.katz@kcg.tech> * Update docs/userguide/configuration.rst Co-authored-by: Omer Katz <omer.katz@kcg.tech> * Update docs/userguide/configuration.rst Co-authored-by: Omer Katz <omer.katz@kcg.tech> * Update docs/userguide/configuration.rst Co-authored-by: Omer Katz <omer.katz@kcg.tech> * Update docs/userguide/configuration.rst Co-authored-by: Omer Katz <omer.katz@kcg.tech> * Update docs/userguide/configuration.rst Co-authored-by: Omer Katz <omer.katz@kcg.tech> * Update docs/userguide/configuration.rst Co-authored-by: Omer Katz <omer.katz@kcg.tech> * Apply suggestions from code review Co-authored-by: Omer Katz <omer.katz@kcg.tech> * doc(configuration): add version added markers to the new daemonization settings --------- Co-authored-by: Asif Saif Uddin <auvipy@gmail.com> Co-authored-by: Omer Katz <omer.katz@kcg.tech> Co-authored-by: Tomer Nosrati <tomer.nosrati@kcg.tech>
- Loading branch information
1 parent
5d97edc
commit 2576e83
Showing
5 changed files
with
273 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from celery import Celery | ||
|
||
app = Celery(set_as_current=False) | ||
app.config_from_object("t.unit.bin.proj.daemon_config") |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Test config for t/unit/bin/test_deamonization.py | ||
|
||
beat_pidfile = "/tmp/beat.test.pid" | ||
beat_logfile = "/tmp/beat.test.log" | ||
beat_uid = 42 | ||
beat_gid = 4242 | ||
beat_umask = 0o777 | ||
beat_executable = "/beat/bin/python" | ||
|
||
events_pidfile = "/tmp/events.test.pid" | ||
events_logfile = "/tmp/events.test.log" | ||
events_uid = 42 | ||
events_gid = 4242 | ||
events_umask = 0o777 | ||
events_executable = "/events/bin/python" | ||
|
||
worker_pidfile = "/tmp/worker.test.pid" | ||
worker_logfile = "/tmp/worker.test.log" | ||
worker_uid = 42 | ||
worker_gid = 4242 | ||
worker_umask = 0o777 | ||
worker_executable = "/worker/bin/python" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from __future__ import annotations | ||
|
||
from unittest.mock import patch | ||
|
||
import pytest | ||
from click.testing import CliRunner | ||
|
||
from celery.bin.celery import celery | ||
|
||
from .proj import daemon_config as config | ||
|
||
|
||
@pytest.mark.usefixtures('depends_on_current_app') | ||
@pytest.mark.parametrize("daemon", ["worker", "beat", "events"]) | ||
def test_daemon_options_from_config(daemon: str, cli_runner: CliRunner): | ||
|
||
with patch(f"celery.bin.{daemon}.{daemon}.callback") as mock: | ||
cli_runner.invoke(celery, f"-A t.unit.bin.proj.daemon {daemon}") | ||
|
||
mock.assert_called_once() | ||
for param in "logfile", "pidfile", "uid", "gid", "umask", "executable": | ||
assert mock.call_args.kwargs[param] == getattr(config, f"{daemon}_{param}") |