File tree Expand file tree Collapse file tree 5 files changed +14
-7
lines changed Expand file tree Collapse file tree 5 files changed +14
-7
lines changed Original file line number Diff line number Diff line change 8
8
"os"
9
9
"os/signal"
10
10
"syscall"
11
- "time"
12
11
13
12
"github.com/go-playground/validator/v10"
14
13
"github.com/massivemadness/articles-server/internal/api"
@@ -77,12 +76,16 @@ func main() {
77
76
signal .Notify (sigChan , syscall .SIGINT , syscall .SIGTERM )
78
77
<- sigChan
79
78
80
- shutdownCtx , shutdownRelease := context .WithTimeout (context .Background (), 10 * time . Second )
79
+ shutdownCtx , shutdownRelease := context .WithTimeout (context .Background (), cfg . HttpServer . ShutdownTimeout )
81
80
defer shutdownRelease ()
82
81
83
82
if err := httpServer .Shutdown (shutdownCtx ); err != nil {
84
83
zapLogger .Error ("HTTP shutdown error" , zap .Error (err ))
85
84
}
86
85
86
+ if err := httpPrivateServer .Shutdown (shutdownCtx ); err != nil {
87
+ zapLogger .Error ("HTTP shutdown error private" , zap .Error (err ))
88
+ }
89
+
87
90
zapLogger .Info ("Server stopped" )
88
91
}
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ http_server:
7
7
private_port : 8081
8
8
timeout : 4s
9
9
idle_timeout : 60s
10
+ shutdown_timeout : 10s
10
11
11
12
database :
12
13
host : " postgres"
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ http_server:
7
7
private_port : 8081
8
8
timeout : 4s
9
9
idle_timeout : 60s
10
+ shutdown_timeout : 10s
10
11
11
12
database :
12
13
host : " postgres" # service name from docker compose
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ http_server:
7
7
private_port : 8081
8
8
timeout : 4s
9
9
idle_timeout : 60s
10
+ shutdown_timeout : 10s
10
11
11
12
database :
12
13
host : " postgres"
Original file line number Diff line number Diff line change @@ -25,11 +25,12 @@ type Application struct {
25
25
}
26
26
27
27
type HTTPServer struct {
28
- Address string `yaml:"address" env-default:"localhost"`
29
- PublicPort int `yaml:"public_port" env-default:"8080"`
30
- PrivatePort int `yaml:"private_port" env-default:"8081"`
31
- Timeout time.Duration `yaml:"timeout" env-default:"4s"`
32
- IdleTimeout time.Duration `yaml:"idle_timeout" env-default:"60s"`
28
+ Address string `yaml:"address" env-default:"localhost"`
29
+ PublicPort int `yaml:"public_port" env-default:"8080"`
30
+ PrivatePort int `yaml:"private_port" env-default:"8081"`
31
+ Timeout time.Duration `yaml:"timeout" env-default:"4s"`
32
+ IdleTimeout time.Duration `yaml:"idle_timeout" env-default:"60s"`
33
+ ShutdownTimeout time.Duration `yaml:"shutdown_timeout" env-default:"10s"`
33
34
}
34
35
35
36
type Database struct {
You can’t perform that action at this time.
0 commit comments