Skip to content

Commit 8874d42

Browse files
committed
Update for new config stuf
1 parent bde25db commit 8874d42

File tree

3 files changed

+24
-22
lines changed

3 files changed

+24
-22
lines changed

ansible_base/task/__init__.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,19 @@ def get_config():
88
psycopg_params.pop('context') # TODO: remove in inner method, makes non-async, not good
99

1010
return {
11+
"version": 2,
12+
"brokers": {
13+
"pg_notify": {
14+
"config": psycopg_params
15+
# TODO: hook in synchronous connection factory
16+
}
17+
},
1118
"producers": {
12-
"brokers": {
13-
"pg_notify": psycopg_params,
14-
"channels": ["dab_broadcast"],
15-
},
16-
"scheduled": {
17-
"ansible_base.task.tasks.run_task_from_queue": {"schedule": 60},
18-
"ansible_base.task.tasks.manage_lost_tasks": {"schedule": 60*10}
19+
"ScheduledProducer": {
20+
"task_schedule": {
21+
"ansible_base.task.tasks.run_task_from_queue": {"schedule": 60},
22+
"ansible_base.task.tasks.manage_lost_tasks": {"schedule": 60*10}
23+
}
1924
},
2025
},
2126
"pool": {"max_workers": 4}, # TODO: to settings

ansible_base/task/apps.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
from django.apps import AppConfig
22

3+
from dispatcher.config import setup
4+
5+
from ansible_base.task import get_config
6+
37

48
class TaskConfig(AppConfig):
59
default_auto_field = 'django.db.models.BigAutoField'
610
name = 'ansible_base.task'
711
label = 'dab_tas'
812
verbose_name = 'DAB tasking system'
13+
14+
def ready(self):
15+
# Set up dispatcher
16+
setup(get_config())
Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
import asyncio
21
import logging
32

4-
from dispatcher.main import DispatcherMain
5-
6-
from ansible_base.task import get_config
3+
from dispatcher import run_service
74

85
from django.core.management.base import BaseCommand
96
from django.db import connection
@@ -16,17 +13,9 @@ class Command(BaseCommand):
1613
help = "Runs bug checking sanity checks, gets scale metrics, and recommendations for Role Based Access Control"
1714

1815
def handle(self, *args, **options):
19-
dispatcher_config = get_config()
20-
21-
loop = asyncio.get_event_loop()
22-
dispatcher = DispatcherMain(dispatcher_config)
23-
2416
# Borrowed from eda-server, ensure the database connection is closed
2517
connection.close()
2618
cache.close()
27-
try:
28-
loop.run_until_complete(dispatcher.main())
29-
except KeyboardInterrupt:
30-
logger.info("run_worker_dispatch entry point leaving")
31-
finally:
32-
loop.close()
19+
20+
# Configuration is already handled in app .ready method
21+
run_service()

0 commit comments

Comments
 (0)