本项目现已支持 Windows 平台,通过构建标签实现跨平台兼容。
# 在 Windows 上构建
GOOS=windows GOARCH=amd64 go build -o minit.exe .
# 或者在 Linux/macOS 上交叉编译 Windows 版本
GOOS=windows GOARCH=amd64 go build -o minit.exe .
Windows 版本使用以下默认路径:
C:\etc\minit.dC:\var\log\minit这些路径可以通过环境变量覆盖:
set MINIT_UNIT_DIR=C:\MyApp\config set MINIT_LOG_DIR=C:\MyApp\logs
/proc/sysos.Interrupt 信号Kill() 而非 Unix 信号# C:\etc\minit.d\example.yml
kind: daemon
name: my-service
command:
- my-service.exe
- --config
- C:\MyApp\config.toml
dir: C:\MyApp
kind: daemon
name: windows-service
command:
- cmd
- /c
- net start MyService
/ 或转义反斜杠 \\cmd /c 或 powershell -c项目使用以下构建标签实现平台分离:
//go:build !windows - Linux/Unix 平台//go:build windows - Windows 平台相关文件:
main.go / main_windows.go - 主程序入口pkg/mexec/manager.go / pkg/mexec/manager_windows.go - 进程执行器pkg/msetups/setup_*_windows.go - Windows 版本的系统设置模块在为 Windows 平台贡献代码时: