fix remote toolsrv spawn: use tools/ path and emit ready on stderr
This commit is contained in:
parent
b4baddd826
commit
b52643314b
|
|
@ -204,14 +204,13 @@ func SpawnRemote(ctx context.Context, cfg RemoteConfig) (*Process, error) {
|
|||
args = append(args, "--yolo")
|
||||
}
|
||||
|
||||
bootstrap := fmt.Sprintf(`#!/bin/sh
|
||||
set -e
|
||||
bootstrap := fmt.Sprintf(`set -e
|
||||
CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/ollie"
|
||||
mkdir -p "$CACHE_DIR"
|
||||
tar xzf - -C "$CACHE_DIR"
|
||||
export XDG_CONFIG_HOME="$(dirname "$CACHE_DIR")"
|
||||
export PATH="$CACHE_DIR/bin:$PATH"
|
||||
exec "$CACHE_DIR/bin/toolsrv" %s
|
||||
export PATH="$CACHE_DIR/tools:$PATH"
|
||||
exec "$CACHE_DIR/tools/toolsrv" %s
|
||||
`, strings.Join(args, " "))
|
||||
|
||||
// Build SSH command with socket forwarding
|
||||
|
|
@ -226,7 +225,7 @@ exec "$CACHE_DIR/bin/toolsrv" %s
|
|||
sshTarget = host
|
||||
sshArgs = append(sshArgs, "-p", port)
|
||||
}
|
||||
sshArgs = append(sshArgs, sshTarget, "bash -s")
|
||||
sshArgs = append(sshArgs, sshTarget, bootstrap)
|
||||
|
||||
procCtx, cancel := context.WithCancel(ctx)
|
||||
cmd := exec.CommandContext(procCtx, "ssh", sshArgs...)
|
||||
|
|
@ -253,7 +252,7 @@ exec "$CACHE_DIR/bin/toolsrv" %s
|
|||
return nil, fmt.Errorf("ssh start: %w", err)
|
||||
}
|
||||
|
||||
// Send tarball of config dir over stdin
|
||||
// Send tarball of config dir over stdin (the bootstrap script reads it via tar xzf -)
|
||||
if err := writeTarball(stdin, cfgDir); err != nil {
|
||||
cancel()
|
||||
_ = cmd.Process.Kill()
|
||||
|
|
@ -261,14 +260,6 @@ exec "$CACHE_DIR/bin/toolsrv" %s
|
|||
_ = os.Remove(localSock)
|
||||
return nil, fmt.Errorf("send tarball: %w", err)
|
||||
}
|
||||
// Send bootstrap script
|
||||
if _, err := stdin.Write([]byte(bootstrap)); err != nil {
|
||||
cancel()
|
||||
_ = cmd.Process.Kill()
|
||||
_ = cmd.Wait()
|
||||
_ = os.Remove(localSock)
|
||||
return nil, fmt.Errorf("send bootstrap: %w", err)
|
||||
}
|
||||
stdin.Close()
|
||||
|
||||
// Wait for toolsrv to signal ready while continuing to drain stderr for the
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ func main() {
|
|||
defer ln.Close()
|
||||
defer os.Remove(*listenPath)
|
||||
|
||||
logger.Info("listening on %s", *listenPath)
|
||||
logger.Warn("listening on %s", *listenPath)
|
||||
|
||||
// Accept connections
|
||||
go func() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue