Merge pull request #5260 from yousong/bugfix/yousong-winbuild

[RFC] Bugfix/yousong winbuild
This commit is contained in:
yunion-ci-robot
2020-02-27 01:13:16 +08:00
committed by GitHub
13 changed files with 84 additions and 17 deletions
+1
View File
@@ -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}
+1 -4
View File
@@ -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() {
-6
View File
@@ -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":
+11
View File
@@ -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
}
+5
View File
@@ -0,0 +1,5 @@
package fileutils2
func Writable(path string) bool {
return false
}
+15
View File
@@ -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
}
+7
View File
@@ -0,0 +1,7 @@
package procutils
import (
"os/exec"
)
func cmdSetSid(cmd *exec.Cmd) {}
+2 -6
View File
@@ -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
View File
@@ -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
View File
@@ -0,0 +1,11 @@
// +build !windows
package client
import (
"syscall"
)
func newWaitStatus(ws uint32) syscall.WaitStatus {
return syscall.WaitStatus(ws)
}
+11
View File
@@ -0,0 +1,11 @@
package client
import (
"syscall"
)
func newWaitStatus(ws uint32) syscall.WaitStatus {
return syscall.WaitStatus{
ExitCode: ws,
}
}
+15
View File
@@ -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
View File
@@ -0,0 +1,4 @@
package signalutils
func SetDumpStackSignal() {
}