|
|
@ -3,17 +3,18 @@ import json |
|
|
|
import logging |
|
|
|
import logging |
|
|
|
import sys |
|
|
|
import sys |
|
|
|
import asyncio |
|
|
|
import asyncio |
|
|
|
import services.server_service |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import services |
|
|
|
from analytic_unit_worker import AnalyticUnitWorker |
|
|
|
from analytic_unit_worker import AnalyticUnitWorker |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
root = logging.getLogger() |
|
|
|
root = logging.getLogger() |
|
|
|
logger = logging.getLogger('SERVER') |
|
|
|
logger = logging.getLogger('SERVER') |
|
|
|
|
|
|
|
|
|
|
|
worker = None |
|
|
|
worker = None |
|
|
|
server_service = None |
|
|
|
server_service = None |
|
|
|
|
|
|
|
data_service = None |
|
|
|
|
|
|
|
|
|
|
|
root.setLevel(logging.DEBUG) |
|
|
|
root.setLevel(logging.DEBUG) |
|
|
|
|
|
|
|
|
|
|
@ -24,7 +25,6 @@ ch.setFormatter(formatter) |
|
|
|
root.addHandler(ch) |
|
|
|
root.addHandler(ch) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def handle_task(text): |
|
|
|
async def handle_task(text): |
|
|
|
try: |
|
|
|
try: |
|
|
|
task = json.loads(text) |
|
|
|
task = json.loads(text) |
|
|
@ -44,12 +44,21 @@ async def handle_task(text): |
|
|
|
except Exception as e: |
|
|
|
except Exception as e: |
|
|
|
logger.error("Exception: '%s'" % str(e)) |
|
|
|
logger.error("Exception: '%s'" % str(e)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def init_services(): |
|
|
|
|
|
|
|
logger.info("Starting services...") |
|
|
|
|
|
|
|
logger.info("Server...") |
|
|
|
|
|
|
|
server_service = services.ServerService(handle_task) |
|
|
|
|
|
|
|
logger.info("Ok") |
|
|
|
|
|
|
|
logger.info("Data service...") |
|
|
|
|
|
|
|
data_service = services.DataService(server_service) |
|
|
|
|
|
|
|
logger.info("Ok") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return server_service, data_service |
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
if __name__ == "__main__": |
|
|
|
loop = asyncio.get_event_loop() |
|
|
|
loop = asyncio.get_event_loop() |
|
|
|
logger.info("Starting worker...") |
|
|
|
logger.info("Starting worker...") |
|
|
|
worker = AnalyticUnitWorker() |
|
|
|
worker = AnalyticUnitWorker() |
|
|
|
logger.info("Ok") |
|
|
|
logger.info("Ok") |
|
|
|
logger.info("Starting server...") |
|
|
|
server_service, data_service = init_services() |
|
|
|
server_service = services.server_service.ServerService(handle_task) |
|
|
|
|
|
|
|
logger.info("Ok") |
|
|
|
|
|
|
|
loop.run_until_complete(server_service.handle_loop()) |
|
|
|
loop.run_until_complete(server_service.handle_loop()) |
|
|
|