mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-07-18 00:55:50 +00:00
feat(process_label): add process role labeling for PostgreSQL connections
- Introduced a new module to determine the process role based on command-line arguments, enhancing PostgreSQL connection labeling for better monitoring. - Updated the database connection parameters to include the application name derived from the process role. - Added unit tests to validate the process role detection logic for different scenarios, including Celery and uWSGI.
This commit is contained in:
parent
b2496dc4e7
commit
c1ff5e35aa
3 changed files with 55 additions and 0 deletions
18
tests/test_process_label.py
Normal file
18
tests/test_process_label.py
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
from unittest.mock import patch
|
||||
|
||||
from django.test import SimpleTestCase
|
||||
|
||||
from dispatcharr.db.process_label import get_process_role
|
||||
|
||||
|
||||
class ProcessLabelTests(SimpleTestCase):
|
||||
def test_celery_worker_not_labeled_as_uwsgi(self):
|
||||
role = get_process_role(
|
||||
["/dispatcharrpy/bin/celery", "-A", "dispatcharr", "worker"]
|
||||
)
|
||||
self.assertEqual(role, "celery-worker")
|
||||
|
||||
def test_uwsgi_labeled_when_gevent_support(self):
|
||||
with patch.dict("os.environ", {"GEVENT_SUPPORT": "True"}):
|
||||
role = get_process_role(["uwsgi"])
|
||||
self.assertEqual(role, "uwsgi")
|
||||
Loading…
Add table
Add a link
Reference in a new issue