File tree Expand file tree Collapse file tree 3 files changed +24
-22
lines changed Expand file tree Collapse file tree 3 files changed +24
-22
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 11from django .apps import AppConfig
22
3+ from dispatcher .config import setup
4+
5+ from ansible_base .task import get_config
6+
37
48class 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 ())
Original file line number Diff line number Diff line change 1- import asyncio
21import logging
32
4- from dispatcher .main import DispatcherMain
5-
6- from ansible_base .task import get_config
3+ from dispatcher import run_service
74
85from django .core .management .base import BaseCommand
96from 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 ()
You can’t perform that action at this time.
0 commit comments