func InitAction(ctx *cli.Context) { t := time.Now() // check config, // is install time > 0, show installed message // otherwise, set install time and write new config file if app.Config.AppInstallTime > 0 { log.Info("Blog|Installed|%s", time.Unix(app.Config.AppInstallTime, 0).Format(time.RFC3339)) return } app.Config.AppInstallTime = time.Now().Unix() app.Config.Write() // make directories os.Mkdir(app.Config.UserDirectory, os.ModePerm) os.Mkdir(filepath.Join(app.Config.UserDirectory, app.Config.UserThemeDirectory), os.ModePerm) os.Mkdir(filepath.Join(app.Config.UserDirectory, app.Config.UserUploadDirectory), os.ModePerm) // init database schema app.Db = core.NewDatabase(filepath.Join(app.Config.UserDirectory, app.Config.UserDataFile)) action.Call(InitDbSchema, nil) action.Call(InitDbDefault, nil) log.Info("Blog|Install|Success|%.1fms", time.Since(t).Seconds()*1000) }
func ServAction(ctx *cli.Context) { t := time.Now() address := fmt.Sprintf("%s:%s", app.Config.HttpHost, app.Config.HttpAddress) log.Info("Serv|Begin|%s", address) // init global vars app.Db = core.NewDatabase(filepath.Join(app.Config.UserDirectory, app.Config.UserDataFile)) app.Server = core.NewServer(address) // read settings model.ReadSettingsToGlobal() // set other global vars with setting app.Theme = core.NewTheme(filepath.Join(app.Config.UserDirectory, app.Config.UserThemeDirectory), model.Settings["theme"].GetString()) // init server action.Call(InitServer, nil) // init router action.Call(InitRoute, nil) // start server core.Start(app.Server) log.Info("Serv|Close|%.1fms", time.Since(t).Seconds()*1000) }