示例#1
0
文件: main.go 项目: josjevv/khabar
func sysInit() {
	<-(gottp.SysInitChan) //Buffered Channel to receive the server upstart boolean

	config.InitTracer()
	log.Println("Initialized GoTracer")

	db.Conn = db.GetConn(
		config.Settings.Khabar.DBName,
		config.Settings.Khabar.DBAddress,
		config.Settings.Khabar.DBUsername,
		config.Settings.Khabar.DBPassword,
	)

	log.Println("Database Connected :" + config.Settings.Khabar.DBName + " " +
		"at address:" + config.Settings.Khabar.DBAddress)

	transDir := config.Settings.Khabar.TranslationDirectory

	if len(transDir) == 0 {
		cwd := os.Getenv("PWD")
		transDir = cwd + "/translations"
		config.Settings.Khabar.TranslationDirectory = cwd
	}

	log.Println("Directory for translation :" + transDir)

	filepath.Walk(transDir, func(path string, _ os.FileInfo, err error) error {
		fileExt := filepath.Ext(path)
		if fileExt == ".json" && err == nil {
			log.Println("Loading translation file:" + path)
			i18n.MustLoadTranslationFile(path)
		} else {
			log.Print("Skipping translation file:" + path + " " +
				"File Extension:" + fileExt + " ")
			if err != nil {
				log.Print("Error:" + err.Error())
			}
		}
		return nil
	})

	log.SetFlags(log.Ldate | log.Ltime | log.Llongfile)
	log.Println("Translations have been parsed.")
}
示例#2
0
func init() {
	db.Conn = db.GetConn(dbName, "localhost")
	setup()
}