Semaphore/main.go

49 lines
1.1 KiB
Go
Raw Normal View History

2016-01-05 00:32:53 +01:00
package main
import (
"fmt"
2016-03-16 22:49:43 +01:00
"github.com/ansible-semaphore/semaphore/database"
"github.com/ansible-semaphore/semaphore/migration"
"github.com/ansible-semaphore/semaphore/routes"
2016-04-02 14:40:07 +02:00
"github.com/ansible-semaphore/semaphore/routes/sockets"
2016-04-04 15:44:34 +02:00
"github.com/ansible-semaphore/semaphore/routes/tasks"
2016-03-16 22:49:43 +01:00
"github.com/ansible-semaphore/semaphore/util"
2016-01-05 00:32:53 +01:00
"github.com/bugsnag/bugsnag-go"
"github.com/gin-gonic/gin"
)
func main() {
fmt.Printf("Semaphore %v\n", util.Version)
fmt.Printf("Port %v\n", util.Config.Port)
fmt.Printf("MySQL %v@%v\n", util.Config.MySQL.Username, util.Config.MySQL.Hostname)
fmt.Printf("Redis %v\n", util.Config.SessionDb)
fmt.Printf("Tmp Path (projects home) %v\n", util.Config.TmpPath)
2016-01-05 00:32:53 +01:00
defer database.Mysql.Db.Close()
database.RedisPing()
if util.Migration {
fmt.Println("\n Running DB Migrations")
if err := migration.MigrateAll(); err != nil {
panic(err)
}
return
}
2016-04-02 14:40:07 +02:00
go sockets.StartWS()
2016-01-05 00:32:53 +01:00
r := gin.New()
r.Use(gin.Recovery(), recovery, gin.Logger())
routes.Route(r)
2016-04-04 15:44:34 +02:00
go tasks.StartRunner()
2016-01-05 00:32:53 +01:00
r.Run(util.Config.Port)
}
func recovery(c *gin.Context) {
defer bugsnag.AutoNotify()
c.Next()
}