Skip to content

Commit

Permalink
better service commands for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Dedac committed May 19, 2023
1 parent 065161f commit 0ce7d36
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions serviceCommands.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import (
)

func runStart(name string) {
runner := fmt.Sprintf("%s/run.sh", name)
var runner string
if runtime.GOOS != "windows" {
runner = fmt.Sprintf("%s/run.cmd", name)
} else {
runner = fmt.Sprintf("%s/run.sh", name)
}
runcmd := exec.Command(runner)
runcmd.Stdout = os.Stdout
runcmd.Stderr = os.Stderr
Expand All @@ -20,23 +25,28 @@ func runStart(name string) {
}

func runStop(name string) {
//kill the 3 created processes
runnerprocs := fmt.Sprintf("%[1]s/run.sh|%[1]s/bin/Runner.Listener|%[1]s/run-helper.sh", name)
//Find the pid of the runner
c1 := exec.Command("pgrep", "-f", runnerprocs)
//kill the processes
c2 := exec.Command("xargs", "kill")
c2.Stdin, _ = c1.StdoutPipe()
c2.Stdout = os.Stdout
_ = c2.Start()
err := c1.Run()
err2 := c2.Wait()
if runtime.GOOS != "windows" {

if err != nil {
log.Fatal(err)
}
if err2 != nil {
log.Fatal(err)
//kill the 3 created processes
runnerprocs := fmt.Sprintf("%[1]s/run.sh|%[1]s/bin/Runner.Listener|%[1]s/run-helper.sh", name)
//Find the pid of the runner
c1 := exec.Command("pgrep", "-f", runnerprocs)
//kill the processes
c2 := exec.Command("xargs", "kill")
c2.Stdin, _ = c1.StdoutPipe()
c2.Stdout = os.Stdout
_ = c2.Start()
err := c1.Run()
err2 := c2.Wait()

if err != nil {
log.Fatal(err)
}
if err2 != nil {
log.Fatal(err)
}
} else {
//TODO: Implement stop for windows
}
}

Expand Down

0 comments on commit 0ce7d36

Please sign in to comment.