github.com/gigforks/mattermost-server@v4.9.1-0.20180619094218-800d97fa55d0+incompatible/cmd/init.go (about) 1 // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2 // See License.txt for license information. 3 4 package cmd 5 6 import ( 7 "github.com/mattermost/mattermost-server/app" 8 "github.com/mattermost/mattermost-server/model" 9 "github.com/mattermost/mattermost-server/utils" 10 "github.com/spf13/cobra" 11 ) 12 13 func InitDBCommandContextCobra(cmd *cobra.Command) (*app.App, error) { 14 config, err := cmd.Flags().GetString("config") 15 if err != nil { 16 return nil, err 17 } 18 19 a, err := InitDBCommandContext(config) 20 if err != nil { 21 // Returning an error just prints the usage message, so actually panic 22 panic(err) 23 } 24 25 a.DoAdvancedPermissionsMigration() 26 27 return a, nil 28 } 29 30 func InitDBCommandContext(configFileLocation string) (*app.App, error) { 31 if err := utils.TranslationsPreInit(); err != nil { 32 return nil, err 33 } 34 model.AppErrorInit(utils.T) 35 36 a, err := app.New(app.ConfigFile(configFileLocation)) 37 if err != nil { 38 return nil, err 39 } 40 41 if model.BuildEnterpriseReady == "true" { 42 a.LoadLicense() 43 } 44 45 return a, nil 46 }