-
Notifications
You must be signed in to change notification settings - Fork 23
/
stop_watcher.py
48 lines (36 loc) · 1.41 KB
/
stop_watcher.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import asyncio
from asyncio import Queue
from aiohttp import web
from stopwatcher.accepter import DataAccepter
from stopwatcher.comparer import FortComparer
from stopwatcher.config import config
from stopwatcher.db.accessor import DbAccessor
from stopwatcher.job_worker import JobWorker
from stopwatcher.tileserver import Tileserver
from stopwatcher.watcher_jobs import SetQueue
from stopwatcher.external_db_reader import ExternalDbReader
async def main():
processing_queue = Queue()
job_queue = SetQueue()
if config.tileserver.enable:
tileserver = Tileserver(config.tileserver.url)
else:
tileserver = None
db_accessor = DbAccessor()
await db_accessor.connect(asyncio.get_running_loop())
if config.data_input.database:
ExternalDbReader(accessor=db_accessor, process_queue=processing_queue)
if config.data_input.webhooks.enable:
accepter = DataAccepter(process_queue=processing_queue)
asyncio.create_task(
web._run_app(
app=accepter.app,
host=config.data_input.webhooks.host,
port=config.data_input.webhooks.port,
access_log=None
)
)
FortComparer(accessor=db_accessor, inbound_queue=processing_queue, outbound_queue=job_queue)
JobWorker(queue=job_queue, tileserver=tileserver, accessor=db_accessor)
await asyncio.Event().wait()
asyncio.run(main())