新增支持本地windows服务器

This commit is contained in:
郝大全
2018-08-15 00:05:37 +08:00
parent a177c04208
commit 86719ab303

View File

@@ -16,12 +16,14 @@ import (
"runtime/debug"
"time"
"runtime"
"strconv"
"strings"
"github.com/astaxie/beego"
"github.com/george518/PPGo_Job/models"
"github.com/george518/PPGo_Job/notify"
"golang.org/x/crypto/ssh"
"strconv"
"strings"
)
type Job struct {
@@ -72,7 +74,12 @@ func NewCommandJob(id int, name string, command string) *Job {
bufOut := new(bytes.Buffer)
bufErr := new(bytes.Buffer)
//cmd := exec.Command("/bin/bash", "-c", command)
cmd := exec.Command("sh", "-c", command)
var cmd *exec.Cmd
if runtime.GOOS == "windows" {
cmd = exec.Command("sh", "-c", command)
} else {
cmd = exec.Command("CMD", "/C", command)
}
cmd.Stdout = bufOut
cmd.Stderr = bufErr
cmd.Start()