File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import (
10
10
"net/http"
11
11
"os"
12
12
"os/signal"
13
+ "path/filepath"
13
14
"regexp"
14
15
"runtime"
15
16
"strings"
@@ -788,6 +789,21 @@ func handleTermination(lbc *k8s.LoadBalancerController, nginxManager nginx.Manag
788
789
select {
789
790
case err := <- cpcfg .nginxDone :
790
791
if err != nil {
792
+ // removes .sock files after nginx exits
793
+ socketPath := "/var/lib/nginx/"
794
+ files , readErr := os .ReadDir (socketPath )
795
+ if readErr != nil {
796
+ nl .Errorf (lbc .Logger , "error trying to read directory %s: %v" , socketPath , readErr )
797
+ } else {
798
+ for _ , f := range files {
799
+ if ! f .IsDir () && strings .HasSuffix (f .Name (), ".sock" ) {
800
+ fullPath := filepath .Join (socketPath , f .Name ())
801
+ if removeErr := os .Remove (fullPath ); removeErr != nil {
802
+ nl .Errorf (lbc .Logger , "error trying to remove file %s: %v" , fullPath , removeErr )
803
+ }
804
+ }
805
+ }
806
+ }
791
807
nl .Fatalf (lbc .Logger , "nginx command exited unexpectedly with status: %v" , err )
792
808
} else {
793
809
nl .Info (lbc .Logger , "nginx command exited successfully" )
You can’t perform that action at this time.
0 commit comments