36 lines
817 B
Python
36 lines
817 B
Python
import asyncio
|
|
import logging
|
|
import sys
|
|
|
|
from aiohttp.web import Application
|
|
from cachetools import LRUCache
|
|
|
|
from . import set_app
|
|
from . import views
|
|
from .config import DotDict, RelayConfig
|
|
from .database import RelayDatabase
|
|
from .middleware import http_signatures_middleware
|
|
|
|
|
|
app = Application(middlewares=[
|
|
http_signatures_middleware
|
|
])
|
|
|
|
app['config'] = RelayConfig('relay.yaml')
|
|
|
|
if not app['config'].load():
|
|
app['config'].save()
|
|
|
|
logging.error('Relay is not setup. Change the host in relay.yaml at the least and try again')
|
|
sys.exit(1)
|
|
|
|
app['database'] = RelayDatabase(app['config'])
|
|
app['database'].load()
|
|
|
|
app['cache'] = DotDict()
|
|
app['semaphore'] = asyncio.Semaphore(app['config']['push_limit'])
|
|
|
|
for key in app['config'].cachekeys:
|
|
app['cache'][key] = LRUCache(app['config'][key])
|
|
|
|
set_app(app)
|