コード例 #1
0
ファイル: tattoo.go プロジェクト: haegyung/tattoo
func main() {
	flag.Parse()
	if err := GetConfig().Load(); err != nil {
		fmt.Println("Failed to load configure file")
		return
	}
	cfg := GetConfig()
	startUpTime = time.Now().Unix()
	rootPath, _ := os.Getwd()
	rootURL := path.Join(cfg.Path, "/")
	systemStaticPath := path.Join(rootPath, "/sys/static")
	systemStaticURL := path.Join(cfg.Path, "/sys/static")

	themePath := path.Join(rootPath, "theme")
	themeURL := path.Join(cfg.Path, "/theme")

	app := webapp.App{}
	app.Log("App Starts", "OK")
	app.SetStaticPath(systemStaticURL, systemStaticPath)
	app.SetStaticPath(themeURL, themePath)
	app.SetHandler(rootURL, HandleRoot)

	// Load DB
	app.Log("Tattoo DB", "Load DB")
	TattooDB.Load(&app)

	TattooDB.SetVar("RootURL", rootURL)
	TattooDB.SetVar("SystemStaticURL", systemStaticURL)

	// load templates
	if err := LoadSystemTemplates(); err != nil {
		app.Log("Error", fmt.Sprintf("Failed to load system templates: %v", err))
		return
	}
	if err := LoadTheme(&app, GetConfig().ThemeName); err != nil {
		app.Log("Error", fmt.Sprintf("Failed to load theme: %v", err))
	}

	// Start Server.
	if *useFCGI {
		log.Printf("Server Starts(FastCGI): Listen on port %d\n", GetConfig().Port)
		app.RunCGI(GetConfig().Port)
	} else {
		log.Printf("Server Starts: Listen on port %d\n", GetConfig().Port)
		app.Run(GetConfig().Port)
	}
}
コード例 #2
0
ファイル: bd.go プロジェクト: zorayoyo/blahdy
func main() {
	flag.Parse()

	rootPath, _ := os.Getwd()
	rootPath += ""
	app := webapp.App{}
	app.Log("App Starts", "OK")
	app.SetStaticPath("/static", path.Join(rootPath, "/static"))
	app.SetHandler("/api/", HandleRoot)

	BlahdyDB.Load(&app)
	LoadSamples()

	// Start Server.
	if *useFCGI {
		log.Printf("Server Starts(FastCGI): Listen on port %d\n", 4321)
		app.RunCGI(4321)
	} else {
		log.Printf("Server Starts: Listen on port %d\n", 8888)
		app.Run(8888)
	}
}