mirror of https://github.com/status-im/consul.git
agent/proxy: fix build on Windows
This commit is contained in:
parent
070c91cb23
commit
316bdbe010
|
@ -8,7 +8,6 @@ import (
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/consul/lib/file"
|
"github.com/hashicorp/consul/lib/file"
|
||||||
|
@ -255,9 +254,9 @@ func (p *Daemon) start() (*os.Process, error) {
|
||||||
cmd.Args = []string{cmd.Path}
|
cmd.Args = []string{cmd.Path}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start it in a new sessions (and hence process group) so that killing agent
|
// Perform system-specific setup. In particular, Unix-like systems
|
||||||
// (even with Ctrl-C) won't kill proxy.
|
// shuld set sid so that killing the agent doesn't kill the daemon.
|
||||||
cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
|
configureDaemon(&cmd)
|
||||||
|
|
||||||
// Start it
|
// Start it
|
||||||
p.Logger.Printf("[DEBUG] agent/proxy: starting proxy: %q %#v", cmd.Path, cmd.Args[1:])
|
p.Logger.Printf("[DEBUG] agent/proxy: starting proxy: %q %#v", cmd.Path, cmd.Args[1:])
|
||||||
|
|
|
@ -5,6 +5,7 @@ package proxy
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -28,3 +29,10 @@ func findProcess(pid int) (*os.Process, error) {
|
||||||
|
|
||||||
return nil, fmt.Errorf("process %d is dead or running as another user", pid)
|
return nil, fmt.Errorf("process %d is dead or running as another user", pid)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// configureDaemon is called prior to Start to allow system-specific setup.
|
||||||
|
func configureDaemon(cmd *exec.Cmd) {
|
||||||
|
// Start it in a new sessions (and hence process group) so that killing agent
|
||||||
|
// (even with Ctrl-C) won't kill proxy.
|
||||||
|
cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
|
||||||
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ package proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
)
|
)
|
||||||
|
|
||||||
func findProcess(pid int) (*os.Process, error) {
|
func findProcess(pid int) (*os.Process, error) {
|
||||||
|
@ -12,3 +13,7 @@ func findProcess(pid int) (*os.Process, error) {
|
||||||
// non-nil means it seems to be healthy.
|
// non-nil means it seems to be healthy.
|
||||||
return os.FindProcess(pid)
|
return os.FindProcess(pid)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func configureDaemon(cmd *exec.Cmd) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue