Skip to content

Commit 37272ca

Browse files
committed
fix: wire DockerSocket config and keep VM alive after entrypoint exits
Two fixes for macOS development: 1. Wire cfg.Build.DockerSocket into builds.Config so the config file value (e.g. Colima socket path) is actually used instead of always falling back to /var/run/docker.sock. 2. Restore pre-PR#99 behavior of keeping the VM alive after the entrypoint exits by waiting on the guest-agent. PR#99 changed init to immediately power off the VM when the entrypoint exits, which breaks images like alpine:latest whose CMD is /bin/sh — the shell gets no stdin and exits instantly, killing the VM before anyone can `hm exec` into it. The guest-agent keeps the VM alive and accessible until an explicit stop/delete.
1 parent 3696d16 commit 37272ca

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/providers/providers.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ func ProvideBuildManager(p *paths.Paths, cfg *config.Config, instanceManager ins
289289
RegistryCACert: registryCACert,
290290
DefaultTimeout: cfg.Build.Timeout,
291291
RegistrySecret: cfg.JwtSecret, // Use same secret for registry tokens
292+
DockerSocket: cfg.Build.DockerSocket,
292293
}
293294

294295
// Configure secret provider (use NoOpSecretProvider as fallback to avoid nil panics)

lib/system/init/mode_exec.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,16 @@ func runExecMode(log *Logger, cfg *vmconfig.Config) {
137137
// discovers the VM has stopped (socket gone -> Stopped state).
138138
log.Info("hypeman-init:entrypoint", formatExitSentinel(exitCode, exitMsg))
139139

140+
// Keep VM alive by waiting on the guest-agent. The agent runs forever,
141+
// so the VM stays accessible via `hm exec` even after the entrypoint
142+
// exits (e.g. alpine's /bin/sh exits immediately without stdin).
143+
// The VM is shut down when a stop/delete signal arrives (forwarded above)
144+
// or when the guest-agent's Shutdown RPC sends SIGTERM to PID 1.
145+
if agentCmd != nil && agentCmd.Process != nil {
146+
log.Info("hypeman-init:entrypoint", "entrypoint finished, waiting on guest-agent to keep VM alive")
147+
agentCmd.Wait()
148+
}
149+
140150
// Clean shutdown: use reboot(POWER_OFF) instead of syscall.Exit to avoid
141151
// kernel panic ("Attempted to kill init!"). This cleanly terminates the VM
142152
// and causes the hypervisor process to exit on the host.

0 commit comments

Comments
 (0)