From 72cb7f5e140b332a0486edfe7f06404a94545c7a Mon Sep 17 00:00:00 2001 From: Manuel Alejandro de Brito Fontes Date: Fri, 30 Aug 2019 20:18:11 -0400 Subject: [PATCH] Move nginx helper (#4501) --- internal/ingress/controller/nginx.go | 2 +- internal/ingress/controller/process/nginx.go | 12 ------------ internal/nginx/main.go | 13 +++++++++++++ 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/internal/ingress/controller/nginx.go b/internal/ingress/controller/nginx.go index 4e7fd1060..f640ba54b 100644 --- a/internal/ingress/controller/nginx.go +++ b/internal/ingress/controller/nginx.go @@ -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 diff --git a/internal/ingress/controller/process/nginx.go b/internal/ingress/controller/process/nginx.go index 2f31dbc80..a0aa44d90 100644 --- a/internal/ingress/controller/process/nginx.go +++ b/internal/ingress/controller/process/nginx.go @@ -24,7 +24,6 @@ import ( "syscall" "time" - ps "github.com/mitchellh/go-ps" "github.com/ncabatoff/process-exporter/proc" "k8s.io/klog" ) @@ -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 -} diff --git a/internal/nginx/main.go b/internal/nginx/main.go index 2e596d101..5a86ea7cf 100644 --- a/internal/nginx/main.go +++ b/internal/nginx/main.go @@ -27,6 +27,7 @@ import ( "strings" "time" + ps "github.com/mitchellh/go-ps" "github.com/tv42/httpunix" "k8s.io/klog" ) @@ -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 +}