func (self *Config) Init(version string) { self.Version = version runtime := runtime.GOOS switch runtime { case "darwin": self.DataDir = filepath.Join(os.Getenv("HOME"), ".mediabase/") case "linux": self.DataDir = filepath.Join(os.Getenv("HOME"), ".mediabase/") case "windows": self.DataDir = filepath.Join(os.Getenv("APPDATA"), "mediabase\\") } path := filepath.Join(self.DataDir, "log") if _, err := os.Stat(path); os.IsNotExist(err) { if err = os.Mkdir(path, 0755); err != nil { log.Printf("FATAL: Unable to create folder %s: %s", path, err) os.Exit(255) } } // os.Setenv("GIN_MODE", "release") mlog.Start(mlog.LevelInfo, filepath.Join(self.DataDir, "log", "mediabase.log")) mlog.Info("mediabase v%s starting up on %s ...", self.Version, runtime) self.setupOperatingEnv() self.LoadConfig() self.LoadRegex() }
func TestDb(t *testing.T) { mlog.Start(mlog.LevelInfo, "./log/mediabase.log") mlog.Info("starting up ...") log.Printf("numproc %d", runtime.NumCPU()) tiempo := time.Now() // tiempo := time.Date(2013, time.December, 15,34,0,0,0, time. log.Printf("tiempo-bare: %s\n", tiempo) log.Printf("tiempo-fmt: %s\n", tiempo.Format(time.RFC3339)) log.Printf("tiempo-fmt2: %s\n", tiempo.Format(time.RFC1123Z)) test, err := time.Parse(time.RFC3339, "2013-12-14T16:18:59-05:00") if err != nil { panic(err) } log.Println(test.Format(time.RFC3339)) // n := []myGenre{ // {id: 1, name: "alfa"}, // {id: 2, name: "beta"}, // } // var genres string // for i := 0; i < len(n); i++ { // attr := &n[i] // if genres == "" { // genres = attr.name // } else { // genres += "|" + attr.name // } // } // log.Println(genres) log.Printf("starting up ...") config := model.Config{AppDir: "/Volumes/Users/kayak/Library/Application Support/net.apertoire.mediabase"} log.Printf("after model.config ...") bus := bus.Bus{} log.Printf("after bus.Bus") dal := services.Dal{Bus: &bus, Config: &config} log.Printf("after dal.services") bus.Start() log.Printf("after bus.start") dal.Start() log.Printf("after dal.start") // bus.StoreMovie <- &message.Movie{Title: "september morning"} // bus.StoreMovie <- &message.Movie{Title: "remember how we danced"} // bus.StoreMovie <- &message.Movie{Title: "something happened"} // bus.StoreMovie <- &message.Movie{Title: "what can you do"} // bus.StoreMovie <- &message.Movie{Title: "stella"} // bus.StoreMovie <- &message.Movie{Title: "or else"} // bus.StoreMovie <- &message.Movie{Title: "find out about"} dal.ImportOmdb() // log.Printf("press enter to stop ...") // var input string // fmt.Scanln(&input) dal.Stop() // bus.Stop() }