Beispiel #1
0
func main() {
	if util.InteractiveSetup {
		os.Exit(doSetup())
	}

	if util.Upgrade {
		if err := util.DoUpgrade(util.Version); err != nil {
			panic(err)
		}

		os.Exit(0)
	}

	fmt.Printf("Semaphore %v\n", util.Version)
	fmt.Printf("Port %v\n", util.Config.Port)
	fmt.Printf("MySQL %v@%v %v\n", util.Config.MySQL.Username, util.Config.MySQL.Hostname, util.Config.MySQL.DbName)
	fmt.Printf("Tmp Path (projects home) %v\n", util.Config.TmpPath)

	if err := database.Connect(); err != nil {
		panic(err)
	}

	models.SetupDBLink()

	defer database.Mysql.Db.Close()

	if util.Migration {
		fmt.Println("\n Running DB Migrations")
		if err := database.MigrateAll(); err != nil {
			panic(err)
		}

		return
	}

	go sockets.StartWS()
	r := gin.New()
	r.Use(gin.Recovery(), recovery, gin.Logger())

	api.Route(r)

	go checkUpdates()
	go tasks.StartRunner()
	r.Run(util.Config.Port)
}
Beispiel #2
0
func doUpgrade(c *gin.Context) {
	util.DoUpgrade(util.Version)
}