Skip to content

Commit

Permalink
Move nginx helper (#4501)
Browse files Browse the repository at this point in the history
  • Loading branch information
aledbf authored Aug 31, 2019
1 parent 8740c1b commit 72cb7f5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion internal/ingress/controller/nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ func (n *NGINXController) Stop() error {
// wait for the NGINX process to terminate
timer := time.NewTicker(time.Second * 1)
for range timer.C {
if !process.IsNginxRunning() {
if !nginx.IsRunning() {
klog.Info("NGINX process has stopped")
timer.Stop()
break
Expand Down
12 changes: 0 additions & 12 deletions internal/ingress/controller/process/nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"syscall"
"time"

ps "github.com/mitchellh/go-ps"
"github.com/ncabatoff/process-exporter/proc"
"k8s.io/klog"
)
Expand Down Expand Up @@ -82,14 +81,3 @@ func WaitUntilPortIsAvailable(port int) {
time.Sleep(100 * time.Millisecond)
}
}

// IsNginxRunning returns true if a process with the name 'nginx' is found
func IsNginxRunning() bool {
processes, _ := ps.Processes()
for _, p := range processes {
if p.Executable() == "nginx" {
return true
}
}
return false
}
13 changes: 13 additions & 0 deletions internal/nginx/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"strings"
"time"

ps "github.com/mitchellh/go-ps"
"github.com/tv42/httpunix"
"k8s.io/klog"
)
Expand Down Expand Up @@ -171,3 +172,15 @@ func Version() string {

return string(out)
}

// IsRunning returns true if a process with the name 'nginx' is found
func IsRunning() bool {
processes, _ := ps.Processes()
for _, p := range processes {
if p.Executable() == "nginx" {
return true
}
}

return false
}

0 comments on commit 72cb7f5

Please sign in to comment.