diff options
author | Pierre de La Morinerie <kemenaran@gmail.com> | 2018-02-07 13:41:15 +0530 |
---|---|---|
committer | Chris <ccbrown112@gmail.com> | 2018-02-07 02:11:15 -0600 |
commit | 809a16458f7483a2b762cd546493780fea6220ea (patch) | |
tree | b49abb075d1d6cc73a694423c2be441eb947a38e /cmd/platform/test.go | |
parent | 9a73f9988588b6b1be5711634239381fe9e01d16 (diff) | |
download | chat-809a16458f7483a2b762cd546493780fea6220ea.tar.gz chat-809a16458f7483a2b762cd546493780fea6220ea.tar.bz2 chat-809a16458f7483a2b762cd546493780fea6220ea.zip |
Abort on critical error during server startup (#8204)
Only a handful of critical errors are present in the codebase.
They all occur during server startup (in `app.StartServer()`).
Currently, when one of these critical error occurs, it is simpled
mentionned in the logs – then the error is discarded, and the app
attempts to continue the execution (and probably fails pretty quickly in
a weird way).
Rather than continuing operations in an unknow state, these errors should
trigger a clean exit.
This commit rewrites critical startup errors to be correctly
propagated, logged, and then terminate the command execution.
Additionnaly, it makes the server return a proper error code to the
shell.
Diffstat (limited to 'cmd/platform/test.go')
-rw-r--r-- | cmd/platform/test.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/cmd/platform/test.go b/cmd/platform/test.go index 036df07de..9ab3fbb36 100644 --- a/cmd/platform/test.go +++ b/cmd/platform/test.go @@ -53,7 +53,11 @@ func webClientTestsCmdF(cmd *cobra.Command, args []string) error { defer a.Shutdown() utils.InitTranslations(a.Config().LocalizationSettings) - a.StartServer() + serverErr := a.StartServer() + if serverErr != nil { + return serverErr + } + api4.Init(a, a.Srv.Router, false) api.Init(a, a.Srv.Router) wsapi.Init(a, a.Srv.WebSocketRouter) @@ -71,7 +75,11 @@ func serverForWebClientTestsCmdF(cmd *cobra.Command, args []string) error { defer a.Shutdown() utils.InitTranslations(a.Config().LocalizationSettings) - a.StartServer() + serverErr := a.StartServer() + if serverErr != nil { + return serverErr + } + api4.Init(a, a.Srv.Router, false) api.Init(a, a.Srv.Router) wsapi.Init(a, a.Srv.WebSocketRouter) |