Update main.py
Browse files
main.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
import os
|
| 2 |
import subprocess
|
| 3 |
import shutil
|
| 4 |
-
import time
|
| 5 |
import sys
|
| 6 |
|
| 7 |
home = os.path.expanduser("~")
|
|
@@ -78,22 +77,12 @@ print("✅ Config and Skills created successfully.")
|
|
| 78 |
print("[2] Launching Hermes Telegram Gateway in Foreground...")
|
| 79 |
hermes_bin = shutil.which("hermes") or "/usr/local/bin/hermes"
|
| 80 |
|
| 81 |
-
#
|
| 82 |
-
process
|
|
|
|
|
|
|
| 83 |
[hermes_bin, "gateway", "run"],
|
| 84 |
env=os.environ,
|
| 85 |
stdout=sys.stdout,
|
| 86 |
stderr=sys.stderr
|
| 87 |
-
)
|
| 88 |
-
|
| 89 |
-
print("🚀 Bot is live on Hugging Face Server! Process managed via Foreground loop...")
|
| 90 |
-
|
| 91 |
-
try:
|
| 92 |
-
while True:
|
| 93 |
-
if process.poll() is not None:
|
| 94 |
-
print("⚠️ Hermes process ended unexpectedly. Restarting gateway run...")
|
| 95 |
-
process = subprocess.Popen([hermes_bin, "gateway", "run"], env=os.environ, stdout=sys.stdout, stderr=sys.stderr)
|
| 96 |
-
time.sleep(30)
|
| 97 |
-
except KeyboardInterrupt:
|
| 98 |
-
print("🛑 Stopping server.")
|
| 99 |
-
process.terminate()
|
|
|
|
| 1 |
import os
|
| 2 |
import subprocess
|
| 3 |
import shutil
|
|
|
|
| 4 |
import sys
|
| 5 |
|
| 6 |
home = os.path.expanduser("~")
|
|
|
|
| 77 |
print("[2] Launching Hermes Telegram Gateway in Foreground...")
|
| 78 |
hermes_bin = shutil.which("hermes") or "/usr/local/bin/hermes"
|
| 79 |
|
| 80 |
+
# Colab wale extra loops aur process tracking poori tarah se removed.
|
| 81 |
+
# Docker direct container process ko handle karega foreground me.
|
| 82 |
+
sys.stdout.flush()
|
| 83 |
+
subprocess.run(
|
| 84 |
[hermes_bin, "gateway", "run"],
|
| 85 |
env=os.environ,
|
| 86 |
stdout=sys.stdout,
|
| 87 |
stderr=sys.stderr
|
| 88 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|