Spaces:
Running
Running
Silence remaining startup log noise
Browse files- workspace-sync.py: set HF_HUB_VERBOSITY=error before huggingface_hub
import. The "No files have been modified..." spam is logger.warning
level inside upload_large_folder workers; setting Python logging
level after import didn't work because hub re-applies its own level
from the env var on import. Drop emoji prefixes from our own prints.
- cloudflare-proxy.js: switch banner dedupe from process.env to
/tmp/.cf-proxy-banner-shown file marker. Children spawn from bash
(not Node), so an env-var marker set by the parent Node doesn't
propagate. /tmp resets per container so the banner still shows once
per deploy.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- cloudflare-proxy.js +15 -6
- workspace-sync.py +20 -18
cloudflare-proxy.js
CHANGED
|
@@ -347,12 +347,21 @@ if (PROXY_URL) {
|
|
| 347 |
return exports;
|
| 348 |
};
|
| 349 |
|
| 350 |
-
// Startup banner:
|
| 351 |
-
//
|
| 352 |
-
//
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 356 |
}
|
| 357 |
} catch (error) {
|
| 358 |
log(`[cloudflare-proxy] Failed to initialize: ${error.message}`);
|
|
|
|
| 347 |
return exports;
|
| 348 |
};
|
| 349 |
|
| 350 |
+
// Startup banner: print once across all Node spawns. Use a file marker
|
| 351 |
+
// because every Node process (health-server, gateway, sync subprocess)
|
| 352 |
+
// is spawned fresh from bash with NODE_OPTIONS=--require, so an env-var
|
| 353 |
+
// marker won't propagate. /tmp is per-container so it resets on rebuild.
|
| 354 |
+
if (DEBUG) {
|
| 355 |
+
try {
|
| 356 |
+
require("fs").writeFileSync("/tmp/.cf-proxy-banner-shown", "1", {
|
| 357 |
+
flag: "wx",
|
| 358 |
+
});
|
| 359 |
+
log(
|
| 360 |
+
`[cloudflare-proxy] active (${PROXY_ALL ? "wildcard" : "list"}) -> ${proxy.hostname}`,
|
| 361 |
+
);
|
| 362 |
+
} catch (_) {
|
| 363 |
+
// marker exists β banner already shown by another process
|
| 364 |
+
}
|
| 365 |
}
|
| 366 |
} catch (error) {
|
| 367 |
log(`[cloudflare-proxy] Failed to initialize: ${error.message}`);
|
workspace-sync.py
CHANGED
|
@@ -20,14 +20,19 @@ import time
|
|
| 20 |
from pathlib import Path
|
| 21 |
|
| 22 |
os.environ.setdefault("HF_HUB_DISABLE_PROGRESS_BARS", "1")
|
| 23 |
-
|
| 24 |
-
#
|
| 25 |
-
#
|
| 26 |
-
|
|
|
|
| 27 |
|
| 28 |
from huggingface_hub import HfApi, snapshot_download, upload_folder
|
| 29 |
from huggingface_hub.errors import HfHubHTTPError, RepositoryNotFoundError
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
OPENCLAW_HOME = Path("/home/node/.openclaw")
|
| 32 |
WORKSPACE = OPENCLAW_HOME / "workspace"
|
| 33 |
STATUS_FILE = Path("/tmp/sync-status.json")
|
|
@@ -96,7 +101,7 @@ def snapshot_state_into_workspace() -> None:
|
|
| 96 |
elif source_path.is_file():
|
| 97 |
shutil.copy2(source_path, backup_path)
|
| 98 |
except Exception as exc:
|
| 99 |
-
print(f"
|
| 100 |
|
| 101 |
try:
|
| 102 |
if not WHATSAPP_ENABLED:
|
|
@@ -107,7 +112,7 @@ def snapshot_state_into_workspace() -> None:
|
|
| 107 |
if RESET_MARKER.exists():
|
| 108 |
if WHATSAPP_BACKUP_DIR.exists():
|
| 109 |
shutil.rmtree(WHATSAPP_BACKUP_DIR, ignore_errors=True)
|
| 110 |
-
print("
|
| 111 |
RESET_MARKER.unlink(missing_ok=True)
|
| 112 |
return
|
| 113 |
|
|
@@ -117,7 +122,7 @@ def snapshot_state_into_workspace() -> None:
|
|
| 117 |
file_count = count_files(WHATSAPP_CREDS_DIR)
|
| 118 |
if file_count < 2:
|
| 119 |
if file_count > 0:
|
| 120 |
-
print(f"
|
| 121 |
return
|
| 122 |
|
| 123 |
WHATSAPP_BACKUP_DIR.parent.mkdir(parents=True, exist_ok=True)
|
|
@@ -125,13 +130,12 @@ def snapshot_state_into_workspace() -> None:
|
|
| 125 |
shutil.rmtree(WHATSAPP_BACKUP_DIR, ignore_errors=True)
|
| 126 |
shutil.copytree(WHATSAPP_CREDS_DIR, WHATSAPP_BACKUP_DIR)
|
| 127 |
except Exception as exc:
|
| 128 |
-
print(f"
|
| 129 |
|
| 130 |
|
| 131 |
def restore_embedded_state() -> None:
|
| 132 |
state_backup_root = STATE_DIR / "openclaw"
|
| 133 |
if state_backup_root.is_dir():
|
| 134 |
-
print("π§ Restoring OpenClaw state...")
|
| 135 |
for source_path in state_backup_root.iterdir():
|
| 136 |
name = source_path.name
|
| 137 |
if name in EXCLUDED_STATE_NAMES:
|
|
@@ -139,7 +143,6 @@ def restore_embedded_state() -> None:
|
|
| 139 |
shutil.rmtree(source_path, ignore_errors=True)
|
| 140 |
else:
|
| 141 |
source_path.unlink(missing_ok=True)
|
| 142 |
-
print(f" β· Skipping stale backup entry: {name}")
|
| 143 |
continue
|
| 144 |
target_path = OPENCLAW_HOME / name
|
| 145 |
shutil.rmtree(target_path, ignore_errors=True)
|
|
@@ -150,19 +153,18 @@ def restore_embedded_state() -> None:
|
|
| 150 |
shutil.copytree(source_path, target_path)
|
| 151 |
else:
|
| 152 |
shutil.copy2(source_path, target_path)
|
| 153 |
-
print("
|
| 154 |
|
| 155 |
if WHATSAPP_ENABLED and WHATSAPP_BACKUP_DIR.is_dir():
|
| 156 |
file_count = count_files(WHATSAPP_BACKUP_DIR)
|
| 157 |
if file_count >= 2:
|
| 158 |
-
print("π± Restoring WhatsApp credentials...")
|
| 159 |
shutil.rmtree(WHATSAPP_CREDS_DIR, ignore_errors=True)
|
| 160 |
WHATSAPP_CREDS_DIR.parent.mkdir(parents=True, exist_ok=True)
|
| 161 |
shutil.copytree(WHATSAPP_BACKUP_DIR, WHATSAPP_CREDS_DIR)
|
| 162 |
os.chmod(OPENCLAW_HOME / "credentials", 0o700)
|
| 163 |
-
print("
|
| 164 |
else:
|
| 165 |
-
print(f"
|
| 166 |
|
| 167 |
|
| 168 |
def resolve_backup_namespace() -> str:
|
|
@@ -383,21 +385,21 @@ def loop() -> int:
|
|
| 383 |
write_status("configured", f"Backup loop active for {repo_id} with {INTERVAL}s interval.")
|
| 384 |
except Exception as exc:
|
| 385 |
write_status("error", str(exc))
|
| 386 |
-
print(f"
|
| 387 |
return 1
|
| 388 |
|
| 389 |
last_fingerprint = fingerprint_dir(WORKSPACE)
|
| 390 |
last_marker = metadata_marker(WORKSPACE)
|
| 391 |
|
| 392 |
time.sleep(INITIAL_DELAY)
|
| 393 |
-
print(f"
|
| 394 |
|
| 395 |
while not STOP_EVENT.is_set():
|
| 396 |
try:
|
| 397 |
last_fingerprint, last_marker = sync_once(last_fingerprint, last_marker)
|
| 398 |
except Exception as exc:
|
| 399 |
write_status("error", f"Sync failed: {exc}")
|
| 400 |
-
print(f"
|
| 401 |
|
| 402 |
if STOP_EVENT.wait(INTERVAL):
|
| 403 |
break
|
|
@@ -420,7 +422,7 @@ def main() -> int:
|
|
| 420 |
return 0
|
| 421 |
except Exception as exc:
|
| 422 |
write_status("error", f"Shutdown sync failed: {exc}")
|
| 423 |
-
print(f"
|
| 424 |
return 1
|
| 425 |
if command == "loop":
|
| 426 |
return loop()
|
|
|
|
| 20 |
from pathlib import Path
|
| 21 |
|
| 22 |
os.environ.setdefault("HF_HUB_DISABLE_PROGRESS_BARS", "1")
|
| 23 |
+
# huggingface_hub reads HF_HUB_VERBOSITY at import time and overrides any
|
| 24 |
+
# logging.getLogger().setLevel() we apply afterwards. Set it before import
|
| 25 |
+
# to silence the "No files have been modified..." spam from
|
| 26 |
+
# upload_large_folder workers (logger.warning level).
|
| 27 |
+
os.environ.setdefault("HF_HUB_VERBOSITY", "error")
|
| 28 |
|
| 29 |
from huggingface_hub import HfApi, snapshot_download, upload_folder
|
| 30 |
from huggingface_hub.errors import HfHubHTTPError, RepositoryNotFoundError
|
| 31 |
|
| 32 |
+
# Belt-and-suspenders: also raise the level after import in case the env var
|
| 33 |
+
# wasn't honored (older hub versions, or message logged via a sub-logger).
|
| 34 |
+
logging.getLogger("huggingface_hub").setLevel(logging.ERROR)
|
| 35 |
+
|
| 36 |
OPENCLAW_HOME = Path("/home/node/.openclaw")
|
| 37 |
WORKSPACE = OPENCLAW_HOME / "workspace"
|
| 38 |
STATUS_FILE = Path("/tmp/sync-status.json")
|
|
|
|
| 101 |
elif source_path.is_file():
|
| 102 |
shutil.copy2(source_path, backup_path)
|
| 103 |
except Exception as exc:
|
| 104 |
+
print(f"Warning: could not snapshot OpenClaw state: {exc}")
|
| 105 |
|
| 106 |
try:
|
| 107 |
if not WHATSAPP_ENABLED:
|
|
|
|
| 112 |
if RESET_MARKER.exists():
|
| 113 |
if WHATSAPP_BACKUP_DIR.exists():
|
| 114 |
shutil.rmtree(WHATSAPP_BACKUP_DIR, ignore_errors=True)
|
| 115 |
+
print("Removed backed-up WhatsApp credentials after reset request.")
|
| 116 |
RESET_MARKER.unlink(missing_ok=True)
|
| 117 |
return
|
| 118 |
|
|
|
|
| 122 |
file_count = count_files(WHATSAPP_CREDS_DIR)
|
| 123 |
if file_count < 2:
|
| 124 |
if file_count > 0:
|
| 125 |
+
print(f"WhatsApp backup skipped: credentials incomplete ({file_count} files).")
|
| 126 |
return
|
| 127 |
|
| 128 |
WHATSAPP_BACKUP_DIR.parent.mkdir(parents=True, exist_ok=True)
|
|
|
|
| 130 |
shutil.rmtree(WHATSAPP_BACKUP_DIR, ignore_errors=True)
|
| 131 |
shutil.copytree(WHATSAPP_CREDS_DIR, WHATSAPP_BACKUP_DIR)
|
| 132 |
except Exception as exc:
|
| 133 |
+
print(f"Warning: could not snapshot WhatsApp state: {exc}")
|
| 134 |
|
| 135 |
|
| 136 |
def restore_embedded_state() -> None:
|
| 137 |
state_backup_root = STATE_DIR / "openclaw"
|
| 138 |
if state_backup_root.is_dir():
|
|
|
|
| 139 |
for source_path in state_backup_root.iterdir():
|
| 140 |
name = source_path.name
|
| 141 |
if name in EXCLUDED_STATE_NAMES:
|
|
|
|
| 143 |
shutil.rmtree(source_path, ignore_errors=True)
|
| 144 |
else:
|
| 145 |
source_path.unlink(missing_ok=True)
|
|
|
|
| 146 |
continue
|
| 147 |
target_path = OPENCLAW_HOME / name
|
| 148 |
shutil.rmtree(target_path, ignore_errors=True)
|
|
|
|
| 153 |
shutil.copytree(source_path, target_path)
|
| 154 |
else:
|
| 155 |
shutil.copy2(source_path, target_path)
|
| 156 |
+
print("OpenClaw state restored.")
|
| 157 |
|
| 158 |
if WHATSAPP_ENABLED and WHATSAPP_BACKUP_DIR.is_dir():
|
| 159 |
file_count = count_files(WHATSAPP_BACKUP_DIR)
|
| 160 |
if file_count >= 2:
|
|
|
|
| 161 |
shutil.rmtree(WHATSAPP_CREDS_DIR, ignore_errors=True)
|
| 162 |
WHATSAPP_CREDS_DIR.parent.mkdir(parents=True, exist_ok=True)
|
| 163 |
shutil.copytree(WHATSAPP_BACKUP_DIR, WHATSAPP_CREDS_DIR)
|
| 164 |
os.chmod(OPENCLAW_HOME / "credentials", 0o700)
|
| 165 |
+
print("WhatsApp credentials restored.")
|
| 166 |
else:
|
| 167 |
+
print(f"Warning: saved WhatsApp credentials incomplete ({file_count} files), skipping restore.")
|
| 168 |
|
| 169 |
|
| 170 |
def resolve_backup_namespace() -> str:
|
|
|
|
| 385 |
write_status("configured", f"Backup loop active for {repo_id} with {INTERVAL}s interval.")
|
| 386 |
except Exception as exc:
|
| 387 |
write_status("error", str(exc))
|
| 388 |
+
print(f"Workspace sync error: {exc}")
|
| 389 |
return 1
|
| 390 |
|
| 391 |
last_fingerprint = fingerprint_dir(WORKSPACE)
|
| 392 |
last_marker = metadata_marker(WORKSPACE)
|
| 393 |
|
| 394 |
time.sleep(INITIAL_DELAY)
|
| 395 |
+
print(f"Workspace sync started: every {INTERVAL}s -> {repo_id}")
|
| 396 |
|
| 397 |
while not STOP_EVENT.is_set():
|
| 398 |
try:
|
| 399 |
last_fingerprint, last_marker = sync_once(last_fingerprint, last_marker)
|
| 400 |
except Exception as exc:
|
| 401 |
write_status("error", f"Sync failed: {exc}")
|
| 402 |
+
print(f"Workspace sync failed: {exc}")
|
| 403 |
|
| 404 |
if STOP_EVENT.wait(INTERVAL):
|
| 405 |
break
|
|
|
|
| 422 |
return 0
|
| 423 |
except Exception as exc:
|
| 424 |
write_status("error", f"Shutdown sync failed: {exc}")
|
| 425 |
+
print(f"Workspace sync: shutdown sync failed: {exc}")
|
| 426 |
return 1
|
| 427 |
if command == "loop":
|
| 428 |
return loop()
|