mirror of
https://github.com/F1bonacc1/process-compose.git
synced 2024-08-16 23:10:26 +03:00
add darwin support
This commit is contained in:
parent
52e214c4fa
commit
9c3ab226c9
4
Makefile
4
Makefile
@ -26,6 +26,10 @@ compile:
|
||||
# Windows
|
||||
GOOS=windows GOARCH=amd64 go build -o bin/${BINARY_NAME}-windows-amd64.exe -ldflags="-X main.version=${VERSION}" ./src
|
||||
|
||||
# Darwin
|
||||
GOOS=darwin GOARCH=amd64 go build -o bin/${BINARY_NAME}-darwin-amd64 -ldflags="-X main.version=${VERSION}" ./src
|
||||
GOOS=darwin GOARCH=arm64 go build -o bin/${BINARY_NAME}-darwin-arm64 -ldflags="-X main.version=${VERSION}" ./src
|
||||
|
||||
test:
|
||||
go test -cover ./src/...
|
||||
|
||||
|
@ -10,7 +10,6 @@ import (
|
||||
"runtime"
|
||||
"strconv"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/f1bonacc1/process-compose/src/pclog"
|
||||
@ -66,7 +65,7 @@ func (p *Process) Run() error {
|
||||
for {
|
||||
p.cmd = exec.Command(getRunnerShell(), getRunnerArg(), p.getCommand())
|
||||
p.cmd.Env = p.getProcessEnvironment()
|
||||
p.cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
|
||||
p.setProcArgs()
|
||||
stdout, _ := p.cmd.StdoutPipe()
|
||||
stderr, _ := p.cmd.StderrPipe()
|
||||
go p.handleOutput(stdout, p.handleInfo)
|
||||
@ -100,20 +99,6 @@ func (p *Process) Run() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Process) stop() error {
|
||||
//p.cmd.Process.Kill()
|
||||
if runtime.GOOS == "windows" {
|
||||
kill := exec.Command("TASKKILL", "/T", "/F", "/PID", strconv.Itoa(p.cmd.Process.Pid))
|
||||
return kill.Run()
|
||||
} else {
|
||||
pgid, err := syscall.Getpgid(p.cmd.Process.Pid)
|
||||
if err == nil {
|
||||
return syscall.Kill(-pgid, syscall.SIGKILL)
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Process) getBackoff() time.Duration {
|
||||
backoff := 1
|
||||
if p.procConf.RestartPolicy.BackoffSeconds > backoff {
|
||||
|
17
src/app/process_unix.go
Normal file
17
src/app/process_unix.go
Normal file
@ -0,0 +1,17 @@
|
||||
//go:build !windows
|
||||
|
||||
package app
|
||||
|
||||
import "syscall"
|
||||
|
||||
func (p *Process) stop() error {
|
||||
pgid, err := syscall.Getpgid(p.cmd.Process.Pid)
|
||||
if err == nil {
|
||||
return syscall.Kill(-pgid, syscall.SIGKILL)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *Process) setProcArgs() {
|
||||
p.cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
|
||||
}
|
16
src/app/process_windows.go
Normal file
16
src/app/process_windows.go
Normal file
@ -0,0 +1,16 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func (p *Process) stop() error {
|
||||
//p.cmd.Process.Kill()
|
||||
kill := exec.Command("TASKKILL", "/T", "/F", "/PID", strconv.Itoa(p.cmd.Process.Pid))
|
||||
return kill.Run()
|
||||
}
|
||||
|
||||
func (p *Process) setProcArgs() {
|
||||
//empty for windows
|
||||
}
|
Loading…
Reference in New Issue
Block a user