mirror of
https://git.rwth-aachen.de/acs/public/villas/web-backend-go/
synced 2025-03-30 00:00:12 +01:00
use log package
This commit is contained in:
parent
1c9986337e
commit
81b0110b68
3 changed files with 11 additions and 6 deletions
|
@ -1,8 +1,9 @@
|
||||||
package database
|
package database
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
|
|
||||||
"github.com/jinzhu/gorm"
|
"github.com/jinzhu/gorm"
|
||||||
_ "github.com/jinzhu/gorm/dialects/postgres"
|
_ "github.com/jinzhu/gorm/dialects/postgres"
|
||||||
"log"
|
"log"
|
||||||
|
@ -54,6 +55,8 @@ func InitDB(dbname string, isTest bool) *gorm.DB {
|
||||||
DropTables(db)
|
DropTables(db)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Println("Database connection established")
|
||||||
|
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package healthz
|
package healthz
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"git.rwth-aachen.de/acs/public/villas/web-backend-go/amqp"
|
"git.rwth-aachen.de/acs/public/villas/web-backend-go/amqp"
|
||||||
"git.rwth-aachen.de/acs/public/villas/web-backend-go/database"
|
"git.rwth-aachen.de/acs/public/villas/web-backend-go/database"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ func getHealth(c *gin.Context) {
|
||||||
if len(database.AMQP_URL) != 0 {
|
if len(database.AMQP_URL) != 0 {
|
||||||
err = amqp.CheckConnection()
|
err = amqp.CheckConnection()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err.Error())
|
log.Println(err.Error())
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{
|
c.JSON(http.StatusInternalServerError, gin.H{
|
||||||
"success:": false,
|
"success:": false,
|
||||||
"message": err.Error(),
|
"message": err.Error(),
|
||||||
|
|
8
start.go
8
start.go
|
@ -1,7 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"log"
|
||||||
"git.rwth-aachen.de/acs/public/villas/web-backend-go/amqp"
|
"git.rwth-aachen.de/acs/public/villas/web-backend-go/amqp"
|
||||||
"git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/healthz"
|
"git.rwth-aachen.de/acs/public/villas/web-backend-go/routes/healthz"
|
||||||
"time"
|
"time"
|
||||||
|
@ -71,7 +71,7 @@ func main() {
|
||||||
fmt.Println("Starting AMQP client")
|
fmt.Println("Starting AMQP client")
|
||||||
err := amqp.ConnectAMQP(database.AMQP_URL)
|
err := amqp.ConnectAMQP(database.AMQP_URL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
log.Panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Periodically call the Ping function to check which simulators are still there
|
// Periodically call the Ping function to check which simulators are still there
|
||||||
|
@ -83,12 +83,14 @@ func main() {
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
err = amqp.PingAMQP()
|
err = amqp.PingAMQP()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("AMQP Error: ", err.Error())
|
log.Println("AMQP Error: ", err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
log.Printf("Connected AMQP client to %s", amqpurl)
|
||||||
}
|
}
|
||||||
// server at port 4000 to match frontend's redirect path
|
// server at port 4000 to match frontend's redirect path
|
||||||
r.Run(":4000")
|
r.Run(":4000")
|
||||||
|
|
Loading…
Add table
Reference in a new issue