in server/main.py [0:0]
def __init__(self, args: argparse.Namespace):
print(
"==== Apache Pony Mail (Foal v/%s ~%s) starting... ====" % (PONYMAIL_FOAL_VERSION, PONYMAIL_SERVER_VERSION)
)
# Load configuration
yml = yaml.safe_load(open(args.config))
self.config = plugins.configuration.Configuration(yml)
self.data = plugins.configuration.InterData()
self.handlers = dict()
self.dbpool = asyncio.Queue()
self.runners = plugins.offloader.ExecutorPool()
self.server = None
self.streamlock = asyncio.Lock()
self.api_logger = None
self.foal_version = PONYMAIL_FOAL_VERSION
self.server_version = PONYMAIL_SERVER_VERSION
self.stoppable = False # allow remote stop for tests
self.background_event = asyncio.Event() # for background task to wait on
# Make a pool of database connections for async queries
pool_size = self.config.database.pool_size
if pool_size < 1:
raise ValueError(f"pool_size {pool_size} must be > 0")
for _ in range(0, pool_size): # stop value is exclusive
self.dbpool.put_nowait(plugins.database.Database(self.config.database))
# Load each URL endpoint
if args.testendpoints:
print("** Loading additional testing endpoints **")
self._load_endpoint("testendpoints")
print()
self._load_endpoint("endpoints")
if args.logger:
import logging
es_logger = logging.getLogger('elasticsearch')
es_logger.setLevel(args.logger)
es_logger.addHandler(logging.StreamHandler())
if args.trace:
import logging
es_trace_logger = logging.getLogger('elasticsearch.trace')
es_trace_logger.setLevel(args.trace)
es_trace_logger.addHandler(logging.StreamHandler())
if args.apilog:
import logging
self.api_logger = logging.getLogger('ponymail.apilog')
self.api_logger.setLevel(args.apilog)
self.api_logger.addHandler(logging.StreamHandler())
self.stoppable = args.stoppable
self.refreshable = args.refreshable