all: implement self-upgrade flag from API

So upgrading don't have to be initiated manually, helping large
deployments to upgrade to latest ctrld version easily.
This commit is contained in:
Cuong Manh Le
2025-03-26 23:18:04 +07:00
committed by Cuong Manh Le
parent f27cbe3525
commit c60cf33af3
9 changed files with 175 additions and 4 deletions
+18
View File
@@ -0,0 +1,18 @@
package cli
import (
"syscall"
)
// From: https://learn.microsoft.com/en-us/windows/win32/procthread/process-creation-flags?redirectedfrom=MSDN
// SYSCALL_CREATE_NO_WINDOW set flag to run process without a console window.
const SYSCALL_CREATE_NO_WINDOW = 0x08000000
// sysProcAttrForSelfUpgrade returns *syscall.SysProcAttr instance for running self-upgrade command.
func sysProcAttrForSelfUpgrade() *syscall.SysProcAttr {
return &syscall.SysProcAttr{
CreationFlags: syscall.CREATE_NEW_PROCESS_GROUP | SYSCALL_CREATE_NO_WINDOW,
HideWindow: true,
}
}