Skip to content

fix(media-stack panel): background only the installer in the start command - #960

Open
K4r3s-git wants to merge 1 commit into
MagnaCapax:mainfrom
K4r3s-git:fix/media-stack-panel-launch
Open

K4r3s-git wants to merge 1 commit into
MagnaCapax:mainfrom
K4r3s-git:fix/media-stack-panel-launch

Conversation

@K4r3s-git

Copy link
Copy Markdown

Bug: pmssMediaStackPanelStartCommandBuild() builds

cd HOME && rm -f -- PIDFILE && nohup /bin/bash install-media-stack.sh >/dev/null 2>&1 & echo $! > PIDFILE

The trailing & backgrounds the whole && list, not just the installer:

  1. Pid file disappears. rm -f PIDFILE runs inside the background subshell, usually after the foreground echo $! > PIDFILE, so .install-media-stack-web.pid is gone. The panel never shows the install as running and falls straight to installed once the first app dirs appear.
  2. The Start request blocks for the whole install. The background subshell still holds shell_exec's stdout pipe, so the POST waits for the installer to exit. On a successful install the installer restarts lighttpd/php-cgi at the end, and the request dies with HTTP 502.

This hasn't been visible because the current installer aborts early at #858 (the POST then returns after ~30 s). With a completing installer (#959 applied) the Start button returns 502.

Reproduced on a Pulsed Media seedbox with the same shell and sleep 20 as the installer:

old: returned after 20s, pidfile=MISSING
new: returned after 0s,  pidfile=44082

The Start button also returned 502 there after a complete panel-driven install.

Fix: background only the installer, keep the pid write with it, and detach stdin:

cd HOME && rm -f -- PIDFILE && { nohup /bin/bash install-media-stack.sh </dev/null >/dev/null 2>&1 & echo $! > PIDFILE; }

Test: new testStartCommandReturnsAtOnceAndKeepsPidFile runs the real command against a fake installer that sleeps 3 s. The launch must return in < 2 s and the pid file must name a live process. It fails on the old command (3.01s) and passes with the fix. mediaStackPanelTest.php: 25 tests, 0 failures (1 skipped, as before). php -l OK.

🤖 Generated with Claude Code

…mmand

The start command ended in `... && nohup bash install-media-stack.sh >/dev/null
2>&1 & echo $! > PIDFILE`. The trailing `&` applies to the whole && list, so:

- `rm -f PIDFILE` runs in the background subshell and usually deletes the pid
  file right after `echo $!` wrote it, so the panel never reports the install
  as running.
- The background subshell keeps shell_exec's stdout pipe open until the
  installer exits, so the Start request blocks for the whole install and dies
  with a 502 when the installer restarts lighttpd/php-cgi at the end.

Group the backgrounded installer with the pid write and detach its stdin.

Test: a fake installer sleeping 3s; the launch must return at once and leave a
pid file naming the running process (fails on the old command after 3.01s).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant