fix launcher health check: install curl in alpine, update script + applySettings path

This commit is contained in:
Claus Lohmar 2026-07-11 00:28:44 +01:00
parent 89ea56e255
commit d41d1443a8
3 changed files with 28 additions and 6 deletions

View file

@ -46,15 +46,19 @@ services:
volumes: volumes:
- /opt/nextworkspace/:/opt/nextworkspace/ - /opt/nextworkspace/:/opt/nextworkspace/
working_dir: /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: environment:
- CONFIG_DIR=/opt/nextworkspace/config/nextworkspace - CONFIG_DIR=/opt/nextworkspace/config/nextworkspace
- AUTHELIA_SECRET={AUTHELIA_SECRET} - AUTHELIA_SECRET={AUTHELIA_SECRET}
healthcheck: 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 interval: 30s
timeout: 10s timeout: 10s
retries: 3 retries: 3
start_period: 5s
networks: networks:
- nextwks-net - nextwks-net

20
main.go
View file

@ -712,7 +712,25 @@ func globalSettingsSaveHandler(w http.ResponseWriter, r *http.Request) {
} }
func applySettingsHandler(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() output, err := cmd.CombinedOutput()
if err != nil { if err != nil {
http.Error(w, fmt.Sprintf("Apply failed: %v\n%s", err, string(output)), http.StatusInternalServerError) http.Error(w, fmt.Sprintf("Apply failed: %v\n%s", err, string(output)), http.StatusInternalServerError)

View file

@ -6,8 +6,8 @@ BUILD_DIR="/tmp/nextwks-build"
TARGET_DIR="/opt/nextworkspace" TARGET_DIR="/opt/nextworkspace"
BACKUP_DIR="/opt/backup" BACKUP_DIR="/opt/backup"
NETWORK_NAME="nextwks-net" NETWORK_NAME="nextwks-net"
HEALTH_CHECK_RETRIES=10 HEALTH_CHECK_RETRIES=15
HEALTH_CHECK_INTERVAL=2 HEALTH_CHECK_INTERVAL=3
usage() { usage() {
echo "Usage: $0 [--install|--update|--destroy]" 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..." echo "[*] Running health check..."
for i in $(seq 1 $HEALTH_CHECK_RETRIES); do 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 if [ "$HEALTH" = "OK" ]; then
echo "[OK] NextWorkspace launcher is healthy" echo "[OK] NextWorkspace launcher is healthy"
echo "[OK] https://$DOMAIN/" echo "[OK] https://$DOMAIN/"