diff --git a/compose/stack.yaml b/compose/stack.yaml index eb77cfc..7adae8b 100644 --- a/compose/stack.yaml +++ b/compose/stack.yaml @@ -46,15 +46,19 @@ services: volumes: - /opt/nextworkspace/:/opt/nextworkspace/ working_dir: /opt/nextworkspace - command: /opt/nextworkspace/nextworkspace + command: + - sh + - -c + - "apk add --no-cache curl >/dev/null 2>&1 && exec /opt/nextworkspace/nextworkspace" environment: - CONFIG_DIR=/opt/nextworkspace/config/nextworkspace - AUTHELIA_SECRET={AUTHELIA_SECRET} healthcheck: - test: ["CMD", "wget", "-qO-", "http://127.0.0.1:9000/health"] + test: ["CMD", "curl", "-sf", "http://127.0.0.1:9000/health"] interval: 30s timeout: 10s retries: 3 + start_period: 5s networks: - nextwks-net diff --git a/main.go b/main.go index b350847..ed160a0 100644 --- a/main.go +++ b/main.go @@ -712,7 +712,25 @@ func globalSettingsSaveHandler(w http.ResponseWriter, r *http.Request) { } func applySettingsHandler(w http.ResponseWriter, r *http.Request) { - cmd := exec.Command("/opt/NextWks/deploy.sh") + // Find nextwks.sh in common locations + scriptPaths := []string{ + "/home/master/nextwks.sh", + "/root/nextwks.sh", + "/opt/backup/nextwks.sh", + } + script := "" + for _, p := range scriptPaths { + if _, err := os.Stat(p); err == nil { + script = p + break + } + } + if script == "" { + http.Error(w, `{"success":false,"error":"nextwks.sh not found"}`, http.StatusInternalServerError) + return + } + + cmd := exec.Command("bash", script, "--update") output, err := cmd.CombinedOutput() if err != nil { http.Error(w, fmt.Sprintf("Apply failed: %v\n%s", err, string(output)), http.StatusInternalServerError) diff --git a/tools/nextwks.sh b/tools/nextwks.sh index cab3e95..56d4b88 100755 --- a/tools/nextwks.sh +++ b/tools/nextwks.sh @@ -6,8 +6,8 @@ BUILD_DIR="/tmp/nextwks-build" TARGET_DIR="/opt/nextworkspace" BACKUP_DIR="/opt/backup" NETWORK_NAME="nextwks-net" -HEALTH_CHECK_RETRIES=10 -HEALTH_CHECK_INTERVAL=2 +HEALTH_CHECK_RETRIES=15 +HEALTH_CHECK_INTERVAL=3 usage() { echo "Usage: $0 [--install|--update|--destroy]" @@ -288,7 +288,7 @@ podman-compose -f "$TARGET_DIR/compose/stack.yaml" up -d 2>&1 || echo "[WARN] St # ============================================================ echo "[*] Running health check..." for i in $(seq 1 $HEALTH_CHECK_RETRIES); do - HEALTH=$(podman exec launcher wget -qO- http://127.0.0.1:9000/health 2>/dev/null || echo "") + HEALTH=$(podman exec launcher curl -sf http://127.0.0.1:9000/health 2>/dev/null || echo "") if [ "$HEALTH" = "OK" ]; then echo "[OK] NextWorkspace launcher is healthy" echo "[OK] https://$DOMAIN/"