-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
36 lines (29 loc) · 1.32 KB
/
run.py
File metadata and controls
36 lines (29 loc) · 1.32 KB
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
import uvicorn
import argparse
import sys
from dotenv import load_dotenv
from app.utils.jwt import check_jwt_exists
from app.db.sqlite import init_db
from app.logic.config_parser import config
def main():
load_dotenv()
check_jwt_exists()
init_db()
if config["federation_enabled"] and not config["YOUR_DOMAIN_OR_IP"]:
sys.exit("You must add your domain name (or IP address) in app/config.json in order to allow federation support.")
parser = argparse.ArgumentParser(description="Run the Coldwire server")
parser.add_argument("--host", type=str, default="127.0.0.1", help="Host address to bind to (default: 127.0.0.1)")
parser.add_argument("--port", type=int, default=8000, help="Port to bind to (default: 8000)")
parser.add_argument("--workers", type=int, default=4, help="Amount of workers (put same as your CPU cores amount)")
parser.add_argument("--debug", action="store_true", help="Enable debug mode with auto-reload and verbose logging")
args = parser.parse_args()
uvicorn.run(
"app.main:app",
host = args.host,
port = args.port,
reload = args.debug,
workers = 1 if args.debug else args.workers,
log_level = "debug" if args.debug else "info"
)
if __name__ == "__main__":
main()