Files
mattermost/cmd/platform/init.go
T

48 lines
903 B
Go
Raw Normal View History

2016-12-06 10:49:34 -05:00
package main
import (
"fmt"
"github.com/mattermost/platform/app"
2017-01-04 13:41:15 -05:00
"github.com/mattermost/platform/model"
2016-12-06 10:49:34 -05:00
"github.com/mattermost/platform/utils"
"github.com/spf13/cobra"
)
func doLoadConfig(filename string) (err string) {
defer func() {
if r := recover(); r != nil {
err = fmt.Sprintf("%v", r)
}
}()
utils.TranslationsPreInit()
utils.EnableConfigFromEnviromentVars()
2016-12-06 10:49:34 -05:00
utils.LoadConfig(filename)
utils.EnableConfigWatch()
2016-12-06 10:49:34 -05:00
return ""
}
func initDBCommandContextCobra(cmd *cobra.Command) error {
config, err := cmd.Flags().GetString("config")
if err != nil {
return err
}
initDBCommandContext(config)
return nil
}
func initDBCommandContext(configFileLocation string) {
if errstr := doLoadConfig(configFileLocation); errstr != "" {
return
}
utils.ConfigureCmdLineLog()
app.NewServer()
app.InitStores()
2017-01-04 13:41:15 -05:00
if model.BuildEnterpriseReady == "true" {
app.LoadLicense()
2017-01-04 13:41:15 -05:00
}
2016-12-06 10:49:34 -05:00
}