本文整理汇总了Golang中github.com/mattermost/platform/utils.LoadConfig函数的典型用法代码示例。如果您正苦于以下问题:Golang LoadConfig函数的具体用法?Golang LoadConfig怎么用?Golang LoadConfig使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LoadConfig函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestSqlStore1
func TestSqlStore1(t *testing.T) {
utils.LoadConfig("config.json")
utils.Cfg.SqlSettings.Trace = true
store := NewSqlStore()
store.Close()
utils.LoadConfig("config.json")
}
示例2: TestSqlStore3
func TestSqlStore3(t *testing.T) {
defer func() {
if r := recover(); r == nil {
t.Fatal("should have been fatal")
}
}()
utils.LoadConfig("config.json")
utils.Cfg.SqlSettings.DataSource = "missing"
store = NewSqlStore()
utils.LoadConfig("config.json")
}
示例3: main
func main() {
pwd, _ := os.Getwd()
fmt.Println("Current working directory is set to " + pwd)
var config = flag.String("config", "config.json", "path to config file")
flag.Parse()
utils.LoadConfig(*config)
api.NewServer()
api.InitApi()
web.InitWeb()
api.StartServer()
// If we allow testing then listen for manual testing URL hits
if utils.Cfg.ServiceSettings.AllowTesting {
manualtesting.InitManualTesting()
}
// wait for kill signal before attempting to gracefully shutdown
// the running service
c := make(chan os.Signal)
signal.Notify(c, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
<-c
api.StopServer()
}
示例4: Setup
func Setup() *TestHelper {
if app.Srv == nil {
utils.TranslationsPreInit()
utils.LoadConfig("config.json")
utils.InitTranslations(utils.Cfg.LocalizationSettings)
utils.Cfg.TeamSettings.MaxUsersPerTeam = 50
*utils.Cfg.RateLimitSettings.Enable = false
utils.Cfg.EmailSettings.SendEmailNotifications = true
utils.Cfg.EmailSettings.SMTPServer = "dockerhost"
utils.Cfg.EmailSettings.SMTPPort = "2500"
utils.Cfg.EmailSettings.FeedbackEmail = "[email protected]"
utils.DisableDebugLogForTest()
app.NewServer()
app.InitStores()
InitRouter()
app.StartServer()
InitApi()
utils.EnableDebugLogForTest()
app.Srv.Store.MarkSystemRanUnitTests()
*utils.Cfg.TeamSettings.EnableOpenServer = true
}
return &TestHelper{}
}
示例5: saveConfig
func saveConfig(c *Context, w http.ResponseWriter, r *http.Request) {
if !c.HasSystemAdminPermissions("getConfig") {
return
}
cfg := model.ConfigFromJson(r.Body)
if cfg == nil {
c.SetInvalidParam("saveConfig", "config")
return
}
if len(cfg.ServiceSettings.ListenAddress) == 0 {
c.SetInvalidParam("saveConfig", "config")
return
}
if cfg.TeamSettings.MaxUsersPerTeam == 0 {
c.SetInvalidParam("saveConfig", "config")
return
}
// TODO run some cleanup validators
utils.SaveConfig(utils.CfgFileName, cfg)
utils.LoadConfig(utils.CfgFileName)
json := utils.Cfg.ToJson()
w.Write([]byte(json))
}
示例6: saveConfig
func saveConfig(c *Context, w http.ResponseWriter, r *http.Request) {
if !c.HasSystemAdminPermissions("getConfig") {
return
}
cfg := model.ConfigFromJson(r.Body)
if cfg == nil {
c.SetInvalidParam("saveConfig", "config")
return
}
cfg.SetDefaults()
utils.Desanitize(cfg)
if err := cfg.IsValid(); err != nil {
c.Err = err
return
}
if err := utils.ValidateLdapFilter(cfg); err != nil {
c.Err = err
return
}
c.LogAudit("")
utils.SaveConfig(utils.CfgFileName, cfg)
utils.LoadConfig(utils.CfgFileName)
rdata := map[string]string{}
rdata["status"] = "OK"
w.Write([]byte(model.MapToJson(rdata)))
}
示例7: saveConfig
func saveConfig(c *Context, w http.ResponseWriter, r *http.Request) {
if !c.HasSystemAdminPermissions("getConfig") {
return
}
cfg := model.ConfigFromJson(r.Body)
if cfg == nil {
c.SetInvalidParam("saveConfig", "config")
return
}
cfg.SetDefaults()
if err := cfg.IsValid(); err != nil {
c.Err = err
return
}
c.LogAudit("")
utils.SaveConfig(utils.CfgFileName, cfg)
utils.LoadConfig(utils.CfgFileName)
json := utils.Cfg.ToJson()
w.Write([]byte(json))
}
示例8: Setup
func Setup() {
if store == nil {
utils.LoadConfig("config.json")
store = NewSqlStore()
store.MarkSystemRanUnitTests()
}
}
示例9: reloadConfig
func reloadConfig(c *Context, w http.ResponseWriter, r *http.Request) {
utils.LoadConfig(utils.CfgFileName)
// start/restart email batching job if necessary
InitEmailBatching()
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
ReturnStatusOK(w)
}
示例10: reloadConfig
func reloadConfig(c *Context, w http.ResponseWriter, r *http.Request) {
if !c.HasSystemAdminPermissions("reloadConfig") {
return
}
utils.LoadConfig(utils.CfgFileName)
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
ReturnStatusOK(w)
}
示例11: Setup
func Setup() {
if Srv == nil {
utils.LoadConfig("config.json")
NewServer()
StartServer()
InitApi()
Client = model.NewClient("http://localhost:" + utils.Cfg.ServiceSettings.Port + "/api/v1")
}
}
示例12: main
func main() {
parseCmds()
utils.InitTranslations()
utils.LoadConfig(flagConfigFile)
if flagRunCmds {
utils.ConfigureCmdLineLog()
}
pwd, _ := os.Getwd()
l4g.Info(utils.T("mattermost.current_version"), model.CurrentVersion, model.BuildNumber, model.BuildDate, model.BuildHash)
l4g.Info(utils.T("mattermost.entreprise_enabled"), model.BuildEnterpriseReady)
l4g.Info(utils.T("mattermost.working_dir"), pwd)
l4g.Info(utils.T("mattermost.config_file"), utils.FindConfigFile(flagConfigFile))
api.NewServer()
api.InitApi()
web.InitWeb()
if model.BuildEnterpriseReady == "true" {
api.LoadLicense()
}
if !utils.IsLicensed && len(utils.Cfg.SqlSettings.DataSourceReplicas) > 1 {
l4g.Critical(utils.T("store.sql.read_replicas_not_licensed.critical"))
time.Sleep(time.Second)
panic(fmt.Sprintf(utils.T("store.sql.read_replicas_not_licensed.critical")))
}
if flagRunCmds {
runCmds()
} else {
api.StartServer()
// If we allow testing then listen for manual testing URL hits
if utils.Cfg.ServiceSettings.EnableTesting {
manualtesting.InitManualTesting()
}
setDiagnosticId()
runSecurityAndDiagnosticsJobAndForget()
if einterfaces.GetComplianceInterface() != nil {
einterfaces.GetComplianceInterface().StartComplianceDailyJob()
}
// wait for kill signal before attempting to gracefully shutdown
// the running service
c := make(chan os.Signal)
signal.Notify(c, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
<-c
api.StopServer()
}
}
示例13: Setup
func Setup() {
if store == nil {
utils.LoadConfig("config.json")
utils.InitTranslations(utils.Cfg.LocalizationSettings)
store = NewSqlStore()
store.MarkSystemRanUnitTests()
}
}
示例14: doLoadConfig
func doLoadConfig(filename string) (err string) {
defer func() {
if r := recover(); r != nil {
err = r.(string)
}
}()
utils.LoadConfig(filename)
return ""
}
示例15: doLoadConfig
func doLoadConfig(filename string) (err string) {
defer func() {
if r := recover(); r != nil {
err = fmt.Sprintf("%v", r)
}
}()
utils.LoadConfig(filename)
return ""
}