feat: 新增 proc nohup 后台运行、docker save/load 内置实现,移除 Podman 支持
- proc.nohup:后台运行命令并将 stdout/stderr 追加写入日志, Unix 下新会话、Windows 下 DETACHED_PROCESS 脱离终端 - docker.save:等价 docker save <镜像> -o <镜像名>.tar,文件名按 仓库名+标签生成(alpine:3.20 → alpine_3.20.tar),传镜像 ID 时 先解析出对应名称;docker.load 改为归档文件作位置参数 - 移除 Podman 支持,所有容器命令只走 docker
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
//go:build windows
|
||||
|
||||
package executor
|
||||
|
||||
import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// prepareNohup applies the Windows half of `nohup ... &`: the child's stdin is
|
||||
// connected to NUL and its stdout and stderr are appended to logFile
|
||||
// ("> output.log 2>&1").
|
||||
//
|
||||
// Windows has no SIGHUP; what the shell's `nohup ... &` buys is independence
|
||||
// from the launching console, which DETACHED_PROCESS provides: the child gets
|
||||
// no console at all, so closing the terminal kopsc ran in does not close the
|
||||
// child either. With detach disabled the child shares kopsc's console.
|
||||
func prepareNohup(cmd *exec.Cmd, logFile *os.File, detach bool) {
|
||||
cmd.Stdout = logFile
|
||||
cmd.Stderr = logFile
|
||||
|
||||
if detach {
|
||||
// DETACHED_PROCESS: start without a console, and do not inherit one.
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{
|
||||
CreationFlags: syscall.CREATE_NEW_PROCESS_GROUP | detachedProcess,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// DETACHED_PROCESS (0x00000008) is not exported by package syscall.
|
||||
const detachedProcess = 0x00000008
|
||||
Reference in New Issue
Block a user