#!/usr/bin/env bash # start-service.sh — startet den watermarks-remover HTTP-Service (Skill "remove-ai-marks") # in der Cloud-Workspace einer Cowork-Sitzung. # # Hintergrund: Die Cloud-Umgebung ist pro Sitzung neu, daher klont dieses Skript # das Repo bei Bedarf neu und startet den Service im Hintergrund. Nach dem Lauf # ist der Service unter http://127.0.0.1:8765 erreichbar (siehe SKILL.md unter # skills/remove-ai-marks/ für die /inspect- und /clean-Endpunkte). # # Aufruf: # bash start-service.sh # # Optional per Umgebungsvariable überschreibbar: # WATERMARKS_REMOVER_DIR Zielordner fürs Repo (Default: $HOME/work/watermarks-remover) # WATERMARKS_REMOVER_HOST Bind-Host (Default: 127.0.0.1) # WATERMARKS_REMOVER_PORT Bind-Port (Default: 8765) set -euo pipefail WORKDIR="${WATERMARKS_REMOVER_DIR:-$HOME/work/watermarks-remover}" REPO_URL="https://github.com/guillaumemeyer/watermarks-remover.git" HOST="${WATERMARKS_REMOVER_HOST:-127.0.0.1}" PORT="${WATERMARKS_REMOVER_PORT:-8765}" LOG="/tmp/wr-server.log" if [ ! -d "$WORKDIR/.git" ]; then echo "==> Klone watermarks-remover nach $WORKDIR ..." git clone --depth 1 "$REPO_URL" "$WORKDIR" else echo "==> Repo bereits vorhanden unter $WORKDIR, überspringe Klonen." fi cd "$WORKDIR" if curl -sf "http://${HOST}:${PORT}/health" >/dev/null 2>&1; then echo "==> Service läuft bereits auf ${HOST}:${PORT}." else echo "==> Starte Service auf ${HOST}:${PORT} (Log: $LOG) ..." nohup python3 service/scripts/server.py --host "$HOST" --port "$PORT" > "$LOG" 2>&1 & disown || true ok=0 for _ in $(seq 1 20); do if curl -sf "http://${HOST}:${PORT}/health" >/dev/null 2>&1; then ok=1 break fi sleep 0.5 done if [ "$ok" -ne 1 ]; then echo "!! Service ist nach 10s nicht erreichbar. Log-Ausschnitt:" tail -n 40 "$LOG" || true exit 1 fi echo "==> Service ist erreichbar." fi echo echo "--- /health ---" curl -s "http://${HOST}:${PORT}/health"; echo echo "--- /capabilities ---" curl -s "http://${HOST}:${PORT}/capabilities"; echo