File tree 2 files changed +12
-2
lines changed
internal/ingress/controller
2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -762,6 +762,10 @@ type Configuration struct {
762
762
// Value Format: server_port: domain, server_port: domain[, server_port: domain]*
763
763
// custom-port-domain: "443: xxx.com, 2443: yyy.com"
764
764
CustomPortDomain map [string ]string `json:"custom-port-domain"`
765
+
766
+ // Sleep time for layer 4 load balancer during stop process
767
+ // Unit: seconds
768
+ MaxSleepTimeForStop int `json:"max-stop-sleep-time-for-stop"`
765
769
}
766
770
767
771
// NewDefault returns the default nginx configuration
@@ -939,6 +943,7 @@ func NewDefault() Configuration {
939
943
MaxRespAddHeaderNum : 2 ,
940
944
MaxRespAppendHeaderNum : 2 ,
941
945
User : "root" ,
946
+ MaxSleepTimeForStop : 35 ,
942
947
}
943
948
944
949
if klog .V (5 ) {
Original file line number Diff line number Diff line change @@ -436,8 +436,13 @@ func (n *NGINXController) Stop() error {
436
436
}
437
437
}
438
438
439
+ cfg := n .store .GetBackendConfiguration ()
440
+ lock .RemoveFile (cfg .StatusTengineFilePath )
441
+ klog .Infof ("Sleeping %v seconds for traffic from layer 4 LB" , cfg .MaxSleepTimeForStop )
442
+ time .Sleep (time .Duration (cfg .MaxSleepTimeForStop ) * time .Second )
443
+
439
444
// send stop signal to Tengine
440
- klog .Info ("Stopping Tengine process" )
445
+ klog .Info ("Stopping Tengine process gracefully " )
441
446
cmd := n .command .ExecCommand ("-s" , "quit" )
442
447
cmd .Stdout = os .Stdout
443
448
cmd .Stderr = os .Stderr
@@ -450,7 +455,7 @@ func (n *NGINXController) Stop() error {
450
455
timer := time .NewTicker (time .Second * 1 )
451
456
for range timer .C {
452
457
if ! nginx .IsRunning () {
453
- klog .Info ("Tengine process has stopped" )
458
+ klog .Info ("Tengine process has stopped gracefully " )
454
459
timer .Stop ()
455
460
break
456
461
}
You can’t perform that action at this time.
0 commit comments