summaryrefslogtreecommitdiffstats
path: root/app/apptestlib.go
diff options
context:
space:
mode:
authorPierre de La Morinerie <kemenaran@gmail.com>2018-02-07 13:41:15 +0530
committerChris <ccbrown112@gmail.com>2018-02-07 02:11:15 -0600
commit809a16458f7483a2b762cd546493780fea6220ea (patch)
treeb49abb075d1d6cc73a694423c2be441eb947a38e /app/apptestlib.go
parent9a73f9988588b6b1be5711634239381fe9e01d16 (diff)
downloadchat-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 'app/apptestlib.go')
-rw-r--r--app/apptestlib.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/app/apptestlib.go b/app/apptestlib.go
index 09afc8f76..016a68bec 100644
--- a/app/apptestlib.go
+++ b/app/apptestlib.go
@@ -96,7 +96,11 @@ func setupTestHelper(enterprise bool) *TestHelper {
if testStore != nil {
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.ListenAddress = ":0" })
}
- th.App.StartServer()
+ serverErr := th.App.StartServer()
+ if serverErr != nil {
+ panic(serverErr)
+ }
+
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.ListenAddress = prevListenAddress })
th.App.Srv.Store.MarkSystemRanUnitTests()