ShellRunner
MMO\core\server · 1 symbol · generated 30 Sep 2026
ShellRunner
ShellRunner.php:78A uniform command runner on top of any iShell -- the local Shell or a remote SSH -- giving every command the same result object with a real exit code, plus dry-run support and the handful of filesystem operations (exists, read, write, symlink, ...) that a deployment needs to perform identically here and over ssh.
- Namespace
MMO\core\server- See
Shell::execSafekeeps its exit code on the shell object instead).rungives code written once againstiShellthe sameShellResulteither way. -rungets that exit code back IN BAND, on stdout:( <cmd> ) 2>&1 ; printf "\n__MMO_EXIT__%d" "$?". Over ssh it therefore never depends onssh2managing to report anexit_statusfor the channel (which it only resolves once the channel is drained and closed) -- the status is just more command output. - merging stderr into stdout by default keeps a command's own progress messages (git, tar, mongodump & co. all write those to stderr) out of the failure path entirely, and sidesteps having to read two streams at once at all. - a command can be recorded instead of run ($dryRun), which is what makes a deployment plan reviewable.
Index
| MARKER | ||
| SHA256 | ||
| dryRun | ||
| readOnly | ||
| sha256Command | ||
| shell | ||
| skipped | ||
| createDir($path, $mode) | Create $path (and its parents) on the target. | |
| debugName() | ||
| exec($cmd, $cwd) | Run $cmd, throwing on any non-zero exit code. | |
| exists($path) | ||
| getShell() | ||
| getSkipped() | ||
| isDir($path) | ||
| isReadOnly($cmd) | ||
| isRemote() | ||
| quote($value) | Quote one value as a single argument for whichever shell this runner talks to. | |
| read($path) | ||
| readlink($path) | ||
| receive($remote, $local) | Copy a file off the target. | |
| run($cmd, $cwd, $mergeStderr) | Run $cmd and always come back with a real exit code. | |
| send($local, $remote) | Copy a local file onto the target (a plain copy when the shell is local). | |
| sha256($path) | ||
| symlink($link, $to) | Point the symlink $link at $to, atomically: a temporary link is created beside it and mv -T'd over it, so the link is never missing -- unlike rm && ln, which leaves a window where the site serv… | |
| test($cmd, $cwd) | ||
| write($path, $content) | Write $content to $path on the target, atomically (write beside it, then mv over it) so a reader can never observe a half-written file -- which matters for the journal. | |
| __construct($shell, $dryRun) |
Constants2
MARKER
SHA256
Properties5
dryRun
- Type
- bool
readOnly
- Type
- array
sha256Command
shell
- Type
- iShell
skipped
- Type
- array
Methods20
createDir($path, $mode)
ShellRunner.php:213Create $path (and its parents) on the target.
debugName()
ShellRunner.php:109| returns | string |
exec($cmd, $cwd)
ShellRunner.php:191Run $cmd, throwing on any non-zero exit code.
exists($path)
ShellRunner.php:203getShell()
ShellRunner.php:113| returns | iShell |
getSkipped()
ShellRunner.php:119| returns | array | the commands skipped so far because of dry-run. |
isDir($path)
ShellRunner.php:208isReadOnly($cmd)
ShellRunner.php:122isRemote()
ShellRunner.php:116quote($value)
ShellRunner.php:139Quote one value as a single argument for whichever shell this runner talks to.
read($path)
ShellRunner.php:219readlink($path)
ShellRunner.php:250receive($remote, $local)
ShellRunner.php:318Copy a file off the target.
run($cmd, $cwd, $mergeStderr)
ShellRunner.php:151Run $cmd and always come back with a real exit code.
| $cmd | string | |
| $cwd = null | null | string | the working directory (passed to the shell, never interpolated into $cmd). |
| $mergeStderr = true | bool | fold stderr into stdout (the default: avoids SSH's stderr-means-failure rule and the two-stream deadlock). Pass false when you genuinely need the two separated. |
| returns | ShellResult |
send($local, $remote)
ShellRunner.php:301Copy a local file onto the target (a plain copy when the shell is local).
sha256($path)
ShellRunner.php:279symlink($link, $to)
ShellRunner.php:262Point the symlink $link at $to, atomically: a temporary link is created beside it and mv -T'd over it, so the link is never missing -- unlike rm && ln, which leaves a window where the site serves nothing.
test($cmd, $cwd)
ShellRunner.php:196write($path, $content)
ShellRunner.php:231Write $content to $path on the target, atomically (write beside it, then mv over it) so a reader can never observe a half-written file -- which matters for the journal.