Example #1
0
func launch(isDebug bool) {
	if !util.FileExists(constants.GameFileFullPath) {
		filters.DumpDefaultGames()
	}
	if !isDebug {
		if !util.FileExists(constants.ConfigFilePath) {
			fmt.Printf("Could not read configuration file '%s' in the '%s' directory.\n",
				constants.ConfigFilename, constants.ConfigDirectory)
			fmt.Printf("You must generate the configuration file with: %s --%s\n",
				os.Args[0], configFlag)
			os.Exit(1)
		}
	}
	// Initialize the application-wide configuration
	config.InitConfig()
	// Initialize the application-wide database connections (panic on failure)
	db.InitDBs()

	if !runSilent {
		printStartInfo()
	}

	if config.Config.SteamConfig.AutoQueryMaster {
		autoQueryGame := filters.GetGameByName(
			config.Config.SteamConfig.AutoQueryGame)
		if autoQueryGame == filters.GameUnspecified {
			fmt.Println("Invalid game specified for automatic timed query!")
			fmt.Printf(
				"You may need to delete: '%s' and/or recreate the config with: %s --%s",
				constants.GameFileFullPath, os.Args[0], configFlag)
			os.Exit(1)
		}
		// HTTP server + API + Steam auto-querier
		go web.Start(runSilent)
		filter := filters.NewFilter(autoQueryGame, filters.SrAll, nil)
		stop := make(chan bool, 1)
		go steam.StartMasterRetrieval(stop, filter, 7,
			config.Config.SteamConfig.TimeBetweenMasterQueries)
		<-stop
	} else {
		// HTTP server + API standalone
		web.Start(runSilent)
	}
}
Example #2
0
func main() {
	flag.Parse()

	if doConfig {
		if !util.FileExists(constants.GameFileFullPath) {
			filters.DumpDefaultGames()
		}
		config.CreateConfig()
		os.Exit(0)
	}

	if useDebugConfig {
		config.CreateDebugConfig()
		constants.IsDebug = true
		launch(true)
	} else {
		launch(false)
	}
}