From 0abc9791d3fda8c0fbbb121c935805b120c3117e Mon Sep 17 00:00:00 2001 From: michael Date: Mon, 23 Jun 2025 19:44:21 +0200 Subject: [PATCH] fix(deployment): resolve OpenBSD rc.d service tracking and deployment workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix OpenBSD service file pexp pattern to match actual running process - Set pexp after sourcing rc.subr to prevent automatic override - Update deployment script process detection from broken furt-lua pattern - Add TTY-based daemon detection in start.sh for service vs development mode - Implement comprehensive deployment workflow with backup and health checks - Enable proper rcctl start/stop/check functionality on OpenBSD Root cause: OpenBSD rc.subr automatically generates pexp from daemon+flags, but actual process (/usr/local/bin/lua src/main.lua) differs from wrapper (start.sh). Solution: Override pexp after rc.subr with correct Lua pattern. Deployment script also had incorrect process detection pattern looking for 'furt-lua' string that doesn't exist in process name. Technical details: - Service file: pexp="/usr/local/bin/lua src/main.lua.*" after rc.subr - Process detection: pgrep -u _furt -f 'src/main.lua' - TTY detection: [ ! -t 0 ] for daemon vs interactive mode - Complete deployment workflow with stop/sync/start/health-check cycle Fixes #77 - OpenBSD rc.d service file problem resolved Related: Deployment automation now fully functional karl→walter --- .gitignore | 3 +++ furt-lua/deployment/openbsd/rc.d-furt | 14 ++++++++++++++ furt-lua/scripts/start.sh | 18 ++++++++++++++++-- scripts/deploy/deploy_walter.sh | 11 +++++++---- 4 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 furt-lua/deployment/openbsd/rc.d-furt diff --git a/.gitignore b/.gitignore index ddd7b00..23b2601 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,9 @@ furt-lua/pid/ # Issue creation scripts (these create issues, don't version them) scripts/gitea-issues/ +# Gitea Tools +tools/gitea/ + # OS generated files .DS_Store .DS_Store? diff --git a/furt-lua/deployment/openbsd/rc.d-furt b/furt-lua/deployment/openbsd/rc.d-furt new file mode 100644 index 0000000..6795644 --- /dev/null +++ b/furt-lua/deployment/openbsd/rc.d-furt @@ -0,0 +1,14 @@ +#!/bin/ksh + +daemon="/usr/local/furt/furt-lua/scripts/start.sh" +daemon_user="_furt" +daemon_cwd="/usr/local/furt/furt-lua" +daemon_flags="start" + +. /etc/rc.d/rc.subr + +# pexp NACH rc.subr überschreiben (Fix für OpenBSD Issue #77) +pexp="/usr/local/bin/lua src/main.lua.*" + +rc_cmd $1 + diff --git a/furt-lua/scripts/start.sh b/furt-lua/scripts/start.sh index 7d1498f..3845823 100755 --- a/furt-lua/scripts/start.sh +++ b/furt-lua/scripts/start.sh @@ -97,6 +97,20 @@ echo -e "${YELLOW}Project directory:${NC} $PROJECT_DIR" echo -e "${YELLOW}Lua paths configured for $LUA_CMD (version $LUA_VER)${NC}" echo "" -# Start server -$LUA_CMD src/main.lua +# Auto-detect service context +if [ ! -t 0 ] || [ ! -t 1 ]; then + # No TTY = Service mode (rcctl) + echo "Starting Furt in daemon mode..." + $LUA_CMD src/main.lua & + echo "Furt started (PID: $!)" +else + # Interactive mode (manual/development) +# echo "Furt HTTP-Server started on 127.0.0.1:8080" +# echo "Press Ctrl+C to stop" + $LUA_CMD src/main.lua +fi + + +# Start server +# $LUA_CMD src/main.lua diff --git a/scripts/deploy/deploy_walter.sh b/scripts/deploy/deploy_walter.sh index 5c12742..a00ea51 100755 --- a/scripts/deploy/deploy_walter.sh +++ b/scripts/deploy/deploy_walter.sh @@ -254,7 +254,7 @@ rollback_deployment() { get_service_status() { # Check if furt process is actually running (regardless of rcctl status) - if walter_exec "ps aux | grep -v grep | grep -q '_furt.*lua.*main.lua'"; then + if walter_exec "pgrep -u _furt -f 'src/main.lua' >/dev/null 2>&1"; then echo "running" else echo "stopped" @@ -424,17 +424,20 @@ fix_service_file() { log_info "Creating correct service file..." walter_exec_as_root "sh -c 'cat > /etc/rc.d/furt << \"EOF\" #!/bin/ksh + daemon=\"$TARGET_DIR/scripts/start.sh\" daemon_user=\"$SERVICE_USER\" daemon_cwd=\"$TARGET_DIR\" daemon_flags=\"start\" -pexp=\"lua.*main.lua\" . /etc/rc.d/rc.subr -rc_bg=YES + +# pexp NACH rc.subr überschreiben (Fix für OpenBSD Issue #77) +pexp=\"/usr/local/bin/lua src/main.lua.*\" + rc_cmd \$1 EOF'" - + # Make service file executable walter_exec_as_root "chmod +x /etc/rc.d/furt"