DaLongZZi commited on
Commit
7d3cdc1
Β·
1 Parent(s): dc1a562

fix: run Hermes gateway without s6 supervision

Browse files
Files changed (4) hide show
  1. .gitattributes +10 -0
  2. Dockerfile +1 -0
  3. README.md +4 -4
  4. start.sh +27 -7
.gitattributes CHANGED
@@ -1,3 +1,13 @@
 
 
 
 
 
 
 
 
 
 
1
  *.7z filter=lfs diff=lfs merge=lfs -text
2
  *.arrow filter=lfs diff=lfs merge=lfs -text
3
  *.bin filter=lfs diff=lfs merge=lfs -text
 
1
+ * text=auto eol=lf
2
+ *.sh text eol=lf
3
+ *.py text eol=lf
4
+ *.js text eol=lf
5
+ *.html text eol=lf
6
+ *.md text eol=lf
7
+ *.yml text eol=lf
8
+ *.yaml text eol=lf
9
+ Dockerfile text eol=lf
10
+
11
  *.7z filter=lfs diff=lfs merge=lfs -text
12
  *.arrow filter=lfs diff=lfs merge=lfs -text
13
  *.bin filter=lfs diff=lfs merge=lfs -text
Dockerfile CHANGED
@@ -114,6 +114,7 @@ RUN echo 'export PATH="/opt/hermes/.venv/bin:/opt/data/.local/bin:$PATH"' \
114
  ENV HERMES_HOME=/opt/data \
115
  HUGGINGMES_APP_DIR=/opt/huggingmes \
116
  HERMES_AGENT_VERSION=${HERMES_AGENT_VERSION} \
 
117
  PYTHONUNBUFFERED=1 \
118
  PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH=/usr/bin/chromium
119
 
 
114
  ENV HERMES_HOME=/opt/data \
115
  HUGGINGMES_APP_DIR=/opt/huggingmes \
116
  HERMES_AGENT_VERSION=${HERMES_AGENT_VERSION} \
117
+ HERMES_GATEWAY_NO_SUPERVISE=1 \
118
  PYTHONUNBUFFERED=1 \
119
  PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH=/usr/bin/chromium
120
 
README.md CHANGED
@@ -74,7 +74,7 @@ Watch a quick walkthrough on YouTube: [Deploying HuggingMes on HF Spaces](https:
74
 
75
  ### Step 1: Duplicate this Space
76
 
77
- [![Duplicate this Space](https://huggingface.co/datasets/huggingface/badges/resolve/main/duplicate-this-space-xl.svg)](https://huggingface.co/spaces/somratpro/HuggingMes?duplicate=true)
78
 
79
  ### Step 2: Add Your Secrets
80
 
@@ -205,9 +205,9 @@ For packages you want installed from day one (before the terminal is even opened
205
  | Variable | What to put in it |
206
  | :--- | :--- |
207
  | `HUGGINGMES_RUN` | Full bash script to run on every startup (multi-line, heredocs, `if` blocks all work) |
208
- | `HUGGINGMES_APT_PACKAGES` | Space-separated apt packages to install |
209
- | `HUGGINGMES_PIP_PACKAGES` | Space-separated Python packages to install |
210
- | `HUGGINGMES_NPM_PACKAGES` | Space-separated npm packages to install globally |
211
 
212
  **Example:**
213
 
 
74
 
75
  ### Step 1: Duplicate this Space
76
 
77
+ [![Duplicate this Space](https://huggingface.co/datasets/huggingface/badges/resolve/main/duplicate-this-space-xl.svg)](https://huggingface.co/spaces/DLZZ021/HuggingMes?duplicate=true)
78
 
79
  ### Step 2: Add Your Secrets
80
 
 
205
  | Variable | What to put in it |
206
  | :--- | :--- |
207
  | `HUGGINGMES_RUN` | Full bash script to run on every startup (multi-line, heredocs, `if` blocks all work) |
208
+ | `HUGGINGMES_APT_PACKAGES` | Space- or comma-separated apt packages to install |
209
+ | `HUGGINGMES_PIP_PACKAGES` | Space- or comma-separated Python packages to install |
210
+ | `HUGGINGMES_NPM_PACKAGES` | Space- or comma-separated npm packages to install globally |
211
 
212
  **Example:**
213
 
start.sh CHANGED
@@ -25,6 +25,7 @@ export API_SERVER_HOST="${API_SERVER_HOST:-127.0.0.1}"
25
  export API_SERVER_PORT="$GATEWAY_API_PORT"
26
  export GATEWAY_HEALTH_URL="${GATEWAY_HEALTH_URL:-http://127.0.0.1:${GATEWAY_API_PORT}}"
27
  export TELEGRAM_WEBHOOK_PORT
 
28
 
29
  echo ""
30
  echo " ╔══════════════════════════════════════════╗"
@@ -304,13 +305,32 @@ config.setdefault("security", {}).setdefault("redact_secrets", True)
304
 
305
  platforms = config.setdefault("platforms", {})
306
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
307
  if os.environ.get("TELEGRAM_BOT_TOKEN"):
308
  telegram = platforms.setdefault("telegram", {})
309
- telegram.setdefault("enabled", True)
310
  extra = telegram.setdefault("extra", {})
311
  if os.environ.get("TELEGRAM_BASE_URL"):
312
- extra.setdefault("base_url", os.environ["TELEGRAM_BASE_URL"])
313
- extra.setdefault("base_file_url", os.environ.get("TELEGRAM_BASE_FILE_URL") or os.environ["TELEGRAM_BASE_URL"])
314
  if os.environ.get("TELEGRAM_ALLOWED_USERS"):
315
  config.setdefault("telegram", {}).setdefault("allow_from", [
316
  item.strip()
@@ -598,7 +618,7 @@ HM_STARTUP_FAILURES=0
598
 
599
  if [ -n "${HUGGINGMES_APT_PACKAGES:-}" ]; then
600
  echo "Installing apt packages from HUGGINGMES_APT_PACKAGES..."
601
- read -r -a HM_APT_PACKAGES <<< "$HUGGINGMES_APT_PACKAGES"
602
  if command -v sudo >/dev/null 2>&1; then
603
  if sudo apt-get update && sudo apt-get install -y "${HM_APT_PACKAGES[@]}"; then
604
  echo "HUGGINGMES_APT_PACKAGES install complete."
@@ -621,7 +641,7 @@ fi
621
 
622
  if [ -n "${HUGGINGMES_PIP_PACKAGES:-}" ]; then
623
  echo "Installing Python packages from HUGGINGMES_PIP_PACKAGES..."
624
- read -r -a HM_PIP_PACKAGES <<< "$HUGGINGMES_PIP_PACKAGES"
625
  if /opt/hermes/.venv/bin/pip install "${HM_PIP_PACKAGES[@]}"; then
626
  echo "HUGGINGMES_PIP_PACKAGES install complete."
627
  else
@@ -632,7 +652,7 @@ fi
632
 
633
  if [ -n "${HUGGINGMES_NPM_PACKAGES:-}" ]; then
634
  echo "Installing npm packages from HUGGINGMES_NPM_PACKAGES..."
635
- read -r -a HM_NPM_PACKAGES <<< "$HUGGINGMES_NPM_PACKAGES"
636
  if npm install -g "${HM_NPM_PACKAGES[@]}"; then
637
  echo "HUGGINGMES_NPM_PACKAGES install complete."
638
  else
@@ -762,7 +782,7 @@ while true; do
762
  fi
763
 
764
  echo "Launching Hermes gateway..."
765
- (hermes gateway run 2>&1 | tee -a "$HERMES_HOME/logs/gateway.log") &
766
  GATEWAY_PID=$!
767
 
768
  ready=false
 
25
  export API_SERVER_PORT="$GATEWAY_API_PORT"
26
  export GATEWAY_HEALTH_URL="${GATEWAY_HEALTH_URL:-http://127.0.0.1:${GATEWAY_API_PORT}}"
27
  export TELEGRAM_WEBHOOK_PORT
28
+ export HERMES_GATEWAY_NO_SUPERVISE="${HERMES_GATEWAY_NO_SUPERVISE:-1}"
29
 
30
  echo ""
31
  echo " ╔══════════════════════════════════════════╗"
 
305
 
306
  platforms = config.setdefault("platforms", {})
307
 
308
+ api_enabled_raw = os.environ.get("API_SERVER_ENABLED", "true").strip().lower()
309
+ api_enabled = api_enabled_raw not in {"0", "false", "no", "off"}
310
+ api_server = platforms.setdefault("api_server", {})
311
+ api_server["enabled"] = api_enabled
312
+ api_extra = api_server.setdefault("extra", {})
313
+ api_extra["host"] = os.environ.get("API_SERVER_HOST", "127.0.0.1")
314
+ try:
315
+ api_extra["port"] = int(os.environ.get("API_SERVER_PORT", "8642"))
316
+ except ValueError:
317
+ api_extra["port"] = 8642
318
+ if os.environ.get("API_SERVER_CORS_ORIGINS"):
319
+ api_extra["cors_origins"] = [
320
+ item.strip()
321
+ for item in os.environ["API_SERVER_CORS_ORIGINS"].split(",")
322
+ if item.strip()
323
+ ]
324
+ if os.environ.get("API_SERVER_MODEL_NAME"):
325
+ api_extra["model_name"] = os.environ["API_SERVER_MODEL_NAME"]
326
+
327
  if os.environ.get("TELEGRAM_BOT_TOKEN"):
328
  telegram = platforms.setdefault("telegram", {})
329
+ telegram["enabled"] = True
330
  extra = telegram.setdefault("extra", {})
331
  if os.environ.get("TELEGRAM_BASE_URL"):
332
+ extra["base_url"] = os.environ["TELEGRAM_BASE_URL"]
333
+ extra["base_file_url"] = os.environ.get("TELEGRAM_BASE_FILE_URL") or os.environ["TELEGRAM_BASE_URL"]
334
  if os.environ.get("TELEGRAM_ALLOWED_USERS"):
335
  config.setdefault("telegram", {}).setdefault("allow_from", [
336
  item.strip()
 
618
 
619
  if [ -n "${HUGGINGMES_APT_PACKAGES:-}" ]; then
620
  echo "Installing apt packages from HUGGINGMES_APT_PACKAGES..."
621
+ read -r -a HM_APT_PACKAGES <<< "${HUGGINGMES_APT_PACKAGES//,/ }"
622
  if command -v sudo >/dev/null 2>&1; then
623
  if sudo apt-get update && sudo apt-get install -y "${HM_APT_PACKAGES[@]}"; then
624
  echo "HUGGINGMES_APT_PACKAGES install complete."
 
641
 
642
  if [ -n "${HUGGINGMES_PIP_PACKAGES:-}" ]; then
643
  echo "Installing Python packages from HUGGINGMES_PIP_PACKAGES..."
644
+ read -r -a HM_PIP_PACKAGES <<< "${HUGGINGMES_PIP_PACKAGES//,/ }"
645
  if /opt/hermes/.venv/bin/pip install "${HM_PIP_PACKAGES[@]}"; then
646
  echo "HUGGINGMES_PIP_PACKAGES install complete."
647
  else
 
652
 
653
  if [ -n "${HUGGINGMES_NPM_PACKAGES:-}" ]; then
654
  echo "Installing npm packages from HUGGINGMES_NPM_PACKAGES..."
655
+ read -r -a HM_NPM_PACKAGES <<< "${HUGGINGMES_NPM_PACKAGES//,/ }"
656
  if npm install -g "${HM_NPM_PACKAGES[@]}"; then
657
  echo "HUGGINGMES_NPM_PACKAGES install complete."
658
  else
 
782
  fi
783
 
784
  echo "Launching Hermes gateway..."
785
+ (hermes gateway run --no-supervise 2>&1 | tee -a "$HERMES_HOME/logs/gateway.log") &
786
  GATEWAY_PID=$!
787
 
788
  ready=false