mirror of
https://github.com/MedzikUser/go-pingbot
synced 2024-08-14 23:57:07 +00:00
fix(log): update trace error log
This commit is contained in:
parent
55b4fb0b14
commit
a880aaf054
4 changed files with 15 additions and 5 deletions
|
@ -20,14 +20,18 @@ func Connect() error {
|
|||
defer cancel()
|
||||
|
||||
Client, err := mongo.Connect(ctx, options.Client().ApplyURI(config.Mongo_URI))
|
||||
if common.CheckErr(err, "connect to db") {
|
||||
if err != nil {
|
||||
common.Log.Error("connect to db", err)
|
||||
|
||||
time.Sleep(2 * time.Second)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
err = Client.Ping(ctx, readpref.Primary())
|
||||
if common.CheckErr(err, "ping db") {
|
||||
if err != nil {
|
||||
common.Log.Error("ping db", err)
|
||||
|
||||
time.Sleep(2 * time.Second)
|
||||
|
||||
return err
|
||||
|
|
|
@ -25,7 +25,9 @@ func loop(url string) {
|
|||
defer cancel()
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, "GET", url, nil)
|
||||
if common.CheckErr(err, "new http request") {
|
||||
if err != nil {
|
||||
common.Log.Error("new http request", err)
|
||||
|
||||
Status.Error++
|
||||
|
||||
return
|
||||
|
|
|
@ -17,7 +17,9 @@ func Status(c *gin.Context) {
|
|||
|
||||
mem := stats.Memory()
|
||||
cpu, err := stats.CPU()
|
||||
common.CheckErr(err, "cpu stat")
|
||||
if err != nil {
|
||||
common.Log.Error("cpu stat", err)
|
||||
}
|
||||
|
||||
var p json
|
||||
|
||||
|
|
|
@ -31,7 +31,9 @@ func Server() {
|
|||
api.ApplyRoutes(router)
|
||||
|
||||
err := router.Run(":" + strconv.Itoa(config.Toml.HTTP.Port))
|
||||
if common.CheckErr(err, "gin server run") {
|
||||
if err != nil {
|
||||
common.Log.Error("gin start http server", err)
|
||||
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue