func init() { //orm.RegisterDataBase("default", "mysql", "root@/gotalk?charset=utf8", 30) beego.AppConfigPath = "../conf/app.conf" beego.ParseConfig() setting.ReadConfig() orm.RunSyncdb("default", true, false) }
func main() { setting.ReadConfig() controllers.SocialInit() beego.EnableAdmin = true beego.SetStaticPath("/static", "static") beego.SetStaticPath("/avatars", "avatars") beego.Run() }
func init() { runtime.GOMAXPROCS(Workers) beego.AppConfigPath = "../conf/app.conf" beego.ParseConfig() setting.ReadConfig() DiscuzDb = beego.AppConfig.String("importer::discuzdb") AvatarPath = beego.AppConfig.String("importer::avatarpath") if err := orm.RegisterDataBase("discuz", "mysql", fmt.Sprintf("%s:%s@tcp(%s:3306)/%s?charset=utf8", setting.MySQLUser, setting.MySQLPassword, setting.MySQLHost, DiscuzDb)+"&loc=Asia%2FShanghai", 30); err != nil { fmt.Println("MySQL error:", err.Error()) return } OrmGotalk = orm.NewOrm() if db, err := orm.GetDB("discuz"); err == nil { Orm, err = orm.NewOrmWithDB("mysql", "discuz", db) if err != nil { fmt.Println("MySQL error:", err.Error()) return } } else { fmt.Println("MySQL error:", err.Error()) return } orm.RunSyncdb("default", true, false) }