MT / runner.py
Nailioq's picture
Upload 7 files
b460680 verified
Raw
History Blame Contribute Delete
1.16 kB
import threading
import sys
import os
# Set uvloop policy if available
try:
import uvloop
import asyncio
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
print("Using uvloop for maximum performance.", flush=True)
except ImportError:
print("uvloop not installed, using default asyncio loop.", flush=True)
import mtprotoproxy
from webui import start_webui
def main():
# Start the Flask WebUI in a background daemon thread
web_thread = threading.Thread(target=start_webui, daemon=True)
web_thread.start()
print("Started WebUI on port 7860.", flush=True)
# We need to simulate arguments to mtprotoproxy if it expects sys.argv[1] as config
if len(sys.argv) < 2:
# Defaulting sys.argv to have config.py as first argument so mtprotoproxy picks it up
sys.argv.append("config.py")
print("Starting MTProto Proxy...", flush=True)
# Start mtprotoproxy main loop
# mtprotoproxy.main() starts the loop and blocks forever
try:
mtprotoproxy.main()
except KeyboardInterrupt:
print("Interrupted by user. Exiting...", flush=True)
if __name__ == "__main__":
main()