report server launch errors (#8189)
When starting the server using `platform server`, errors occuring during startup are not reported in the console. The command exit with a 0 exit code (i.e. "success"), although the server failed to launch. With this change, when an error occurs while initializing the app (like a missing or invalid configuration file): - the error is printed to the console; - the command exit with a "-1" exit code. This allow shell scripts to properly detect the startup failure, and to react to it. Example of error displayed: ``` $ platform server Error: LoadConfig: Error decoding config file=config.json, err=While parsing config: invalid character ':' after top-level value, ``
Этот коммит содержится в:
коммит произвёл
Chris
родитель
2256e23c9e
Коммит
07902b4c91
@@ -28,9 +28,10 @@ const (
|
|||||||
var MaxNotificationsPerChannelDefault int64 = 1000000
|
var MaxNotificationsPerChannelDefault int64 = 1000000
|
||||||
|
|
||||||
var serverCmd = &cobra.Command{
|
var serverCmd = &cobra.Command{
|
||||||
Use: "server",
|
Use: "server",
|
||||||
Short: "Run the Mattermost server",
|
Short: "Run the Mattermost server",
|
||||||
RunE: runServerCmd,
|
RunE: runServerCmd,
|
||||||
|
SilenceUsage: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
func runServerCmd(cmd *cobra.Command, args []string) error {
|
func runServerCmd(cmd *cobra.Command, args []string) error {
|
||||||
@@ -41,11 +42,10 @@ func runServerCmd(cmd *cobra.Command, args []string) error {
|
|||||||
|
|
||||||
disableConfigWatch, _ := cmd.Flags().GetBool("disableconfigwatch")
|
disableConfigWatch, _ := cmd.Flags().GetBool("disableconfigwatch")
|
||||||
|
|
||||||
runServer(config, disableConfigWatch)
|
return runServer(config, disableConfigWatch)
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func runServer(configFileLocation string, disableConfigWatch bool) {
|
func runServer(configFileLocation string, disableConfigWatch bool) error {
|
||||||
options := []app.Option{app.ConfigFile(configFileLocation)}
|
options := []app.Option{app.ConfigFile(configFileLocation)}
|
||||||
if disableConfigWatch {
|
if disableConfigWatch {
|
||||||
options = append(options, app.DisableConfigWatch)
|
options = append(options, app.DisableConfigWatch)
|
||||||
@@ -54,7 +54,7 @@ func runServer(configFileLocation string, disableConfigWatch bool) {
|
|||||||
a, err := app.New(options...)
|
a, err := app.New(options...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l4g.Error(err.Error())
|
l4g.Error(err.Error())
|
||||||
return
|
return err
|
||||||
}
|
}
|
||||||
defer a.Shutdown()
|
defer a.Shutdown()
|
||||||
|
|
||||||
@@ -172,6 +172,8 @@ func runServer(configFileLocation string, disableConfigWatch bool) {
|
|||||||
|
|
||||||
a.Jobs.StopSchedulers()
|
a.Jobs.StopSchedulers()
|
||||||
a.Jobs.StopWorkers()
|
a.Jobs.StopWorkers()
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func runSecurityJob(a *app.App) {
|
func runSecurityJob(a *app.App) {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user