File size: 1,086 Bytes
edb671a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
37
38
39
40
41
"""Launcher that logs everything to a file for debugging."""
import os, sys, time, traceback

LOG = os.path.join(os.path.dirname(__file__), "app.log")

os.environ["SOUNDBROKEN_MOCK"] = "1"
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))

with open(LOG, "w", encoding="utf-8") as log:
    try:
        log.write("=== STARTING ===\n")
        log.flush()

        import gradio as gr
        log.write(f"Gradio version: {gr.__version__}\n")
        log.flush()

        from app import demo
        log.write("App module imported OK\n")
        log.flush()

        log.write(f"Launching on 0.0.0.0:7882 ...\n")
        log.flush()

        demo.launch(server_port=7882, server_name="0.0.0.0", show_error=True)

        log.write("=== LAUNCHED OK ===\n")
        log.flush()

        # Keep alive
        while True:
            time.sleep(10)
            log.write(f"heartbeat {time.strftime('%H:%M:%S')}\n")
            log.flush()

    except Exception as e:
        log.write(f"ERROR: {e}\n")
        log.write(traceback.format_exc())
        log.flush()
        raise