mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Merge pull request #5260 from yousong/bugfix/yousong-winbuild
[RFC] Bugfix/yousong winbuild
This commit is contained in:
@@ -51,6 +51,7 @@ ifdef LIBQEMUIO_PATH
|
||||
X_CGO_LDFLAGS := ${CGO_LDFLAGS_ENV} -laio -lqemuio -lpthread -L ${LIBQEMUIO_PATH}/src
|
||||
endif
|
||||
|
||||
export GOOS ?= linux
|
||||
export GO111MODULE:=on
|
||||
export CGO_CFLAGS = ${X_CGO_CFLAGS}
|
||||
export CGO_LDFLAGS = ${X_CGO_LDFLAGS}
|
||||
|
||||
@@ -405,10 +405,7 @@ func (app *Application) registerCleanShutdown(s *http.Server, onStop func()) {
|
||||
}
|
||||
app.idleConnsClosed = make(chan struct{})
|
||||
|
||||
// dump goroutine stack
|
||||
signalutils.RegisterSignal(func() {
|
||||
utils.DumpAllGoroutineStack(log.Logger().Out)
|
||||
}, syscall.SIGUSR1)
|
||||
signalutils.SetDumpStackSignal()
|
||||
|
||||
quitSignals := []os.Signal{syscall.SIGHUP, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGTERM}
|
||||
signalutils.RegisterSignal(func() {
|
||||
|
||||
@@ -24,8 +24,6 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
|
||||
"yunion.io/x/log"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/util/procutils"
|
||||
@@ -241,10 +239,6 @@ func (hf HostsFile) String() string {
|
||||
return ret
|
||||
}
|
||||
|
||||
func Writable(path string) bool {
|
||||
return unix.Access(path, unix.W_OK) == nil
|
||||
}
|
||||
|
||||
func FsFormatToDiskType(fsFormat string) string {
|
||||
switch {
|
||||
case fsFormat == "swap":
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
// +build !windows
|
||||
|
||||
package fileutils2
|
||||
|
||||
import (
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
func Writable(path string) bool {
|
||||
return unix.Access(path, unix.W_OK) == nil
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package fileutils2
|
||||
|
||||
func Writable(path string) bool {
|
||||
return false
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// +build !windows
|
||||
|
||||
package procutils
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func cmdSetSid(cmd *exec.Cmd) {
|
||||
if cmd.SysProcAttr == nil {
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{}
|
||||
}
|
||||
cmd.SysProcAttr.Setsid = true
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package procutils
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
)
|
||||
|
||||
func cmdSetSid(cmd *exec.Cmd) {}
|
||||
@@ -67,17 +67,13 @@ type defaultExecutor struct{}
|
||||
|
||||
func (e *defaultExecutor) Command(name string, args ...string) Cmd {
|
||||
cmd := exec.Command(name, args...)
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{
|
||||
Setsid: true,
|
||||
}
|
||||
cmdSetSid(cmd)
|
||||
return &defaultCmd{cmd}
|
||||
}
|
||||
|
||||
func (e *defaultExecutor) CommandContext(ctx context.Context, name string, args ...string) Cmd {
|
||||
cmd := exec.CommandContext(ctx, name, args...)
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{
|
||||
Setsid: true,
|
||||
}
|
||||
cmdSetSid(cmd)
|
||||
return &defaultCmd{cmd}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -332,7 +332,7 @@ func (c *Cmd) Wait() error {
|
||||
}
|
||||
return nil
|
||||
} else {
|
||||
return &ExitError{ExitStatus: syscall.WaitStatus(res.ExitStatus)}
|
||||
return &ExitError{ExitStatus: newWaitStatus(res.ExitStatus)}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// +build !windows
|
||||
|
||||
package client
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func newWaitStatus(ws uint32) syscall.WaitStatus {
|
||||
return syscall.WaitStatus(ws)
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func newWaitStatus(ws uint32) syscall.WaitStatus {
|
||||
return syscall.WaitStatus{
|
||||
ExitCode: ws,
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// +build !windows
|
||||
package signalutils
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/utils"
|
||||
)
|
||||
|
||||
func SetDumpStackSignal() {
|
||||
RegisterSignal(func() {
|
||||
utils.DumpAllGoroutineStack(log.Logger().Out)
|
||||
}, syscall.SIGUSR1)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package signalutils
|
||||
|
||||
func SetDumpStackSignal() {
|
||||
}
|
||||
Reference in New Issue
Block a user