-
Notifications
You must be signed in to change notification settings - Fork 13
/
main.py
executable file
·36 lines (33 loc) · 1.08 KB
/
main.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# SPDX-License-Identifier: AGPL-3.0-or-later
# SPDX-FileCopyrightText: 2020 grommunio GmbH
"""
Main file to execute.
Can be used to run the API in stand-alone mode by directly executing the file or
in combination with a WSGI server using the API object as callable
"""
if __name__ == '__main__':
import os
import sys
os.chdir(os.path.dirname(os.path.realpath(__file__)))
from cli import Cli
res = Cli().execute()
sys.exit(res)
else:
from api.core import API # Export to uwsgi server
from cli import Cli
from endpoints import * # Register all endpoints
from tools import config
Cli.initLogging()
error = config.validate()
if error:
raise TypeError("Invalid configuration found - aborting ({})".format(error))
if not config.Config["tasq"].get("disabled", False):
import uwsgi
import uwsgidecorators
from tools.tasq import TasQServer
@uwsgidecorators.postfork
def enableTasQ():
TasQServer.start()
uwsgi.atexit = TasQServer.stop