mirror of
https://github.com/MedzikUser/go-pingbot
synced 2024-08-14 23:57:07 +00:00
chore: rename backend
to ping
This commit is contained in:
parent
614054e446
commit
5ebc9a5b0a
10 changed files with 26 additions and 20 deletions
6
main.go
6
main.go
|
@ -10,9 +10,9 @@ import (
|
||||||
"github.com/MedzikUser/go-utils/common"
|
"github.com/MedzikUser/go-utils/common"
|
||||||
"github.com/MedzikUser/go-utils/updater"
|
"github.com/MedzikUser/go-utils/updater"
|
||||||
"github.com/jpillora/opts"
|
"github.com/jpillora/opts"
|
||||||
"gitlab.com/gaming0skar123/go/pingbot/backend"
|
|
||||||
"gitlab.com/gaming0skar123/go/pingbot/config"
|
"gitlab.com/gaming0skar123/go/pingbot/config"
|
||||||
"gitlab.com/gaming0skar123/go/pingbot/database/mongo"
|
"gitlab.com/gaming0skar123/go/pingbot/database/mongo"
|
||||||
|
"gitlab.com/gaming0skar123/go/pingbot/ping"
|
||||||
"gitlab.com/gaming0skar123/go/pingbot/website"
|
"gitlab.com/gaming0skar123/go/pingbot/website"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.Toml.Options.Stop_After_Ping {
|
if config.Toml.Options.Stop_After_Ping {
|
||||||
backend.StopAfterPing()
|
ping.StopAfterPing()
|
||||||
|
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ func main() {
|
||||||
|
|
||||||
if config.Toml.Backend.Enabled {
|
if config.Toml.Backend.Enabled {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go backend.Ticker()
|
go ping.Ticker()
|
||||||
} else {
|
} else {
|
||||||
log.Warn("Backend -> Disabled")
|
log.Warn("Backend -> Disabled")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package backend
|
package ping
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
|
@ -1,4 +1,4 @@
|
||||||
package backend
|
package ping
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
|
@ -1,4 +1,4 @@
|
||||||
package backend
|
package ping
|
||||||
|
|
||||||
var Status StatusType
|
var Status StatusType
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package backend
|
package ping
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
|
@ -1,4 +1,4 @@
|
||||||
package backend
|
package ping
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
6
pre-commit.sh
Executable file
6
pre-commit.sh
Executable file
|
@ -0,0 +1,6 @@
|
||||||
|
#!/usr/bin/bash
|
||||||
|
|
||||||
|
go mod tidy
|
||||||
|
|
||||||
|
# Lint
|
||||||
|
go fmt ./...
|
|
@ -1,5 +1,5 @@
|
||||||
# MongoDB
|
# MongoDB
|
||||||
MONGODB_URI=mongodb+srv://...
|
MONGO_URI=mongodb+srv://...
|
||||||
|
|
||||||
# GitHub
|
# GitHub
|
||||||
GH_TOKEN=ghp_
|
GH_TOKEN=ghp_
|
||||||
|
|
|
@ -4,14 +4,14 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"gitlab.com/gaming0skar123/go/pingbot/backend"
|
"gitlab.com/gaming0skar123/go/pingbot/ping"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetAll(c *gin.Context) {
|
func GetAll(c *gin.Context) {
|
||||||
backend.Cache()
|
ping.Cache()
|
||||||
|
|
||||||
c.JSON(http.StatusOK, json{
|
c.JSON(http.StatusOK, json{
|
||||||
"success": true,
|
"success": true,
|
||||||
"db": backend.CacheURL,
|
"db": ping.CacheURL,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,8 @@ import (
|
||||||
"github.com/MedzikUser/go-utils/common"
|
"github.com/MedzikUser/go-utils/common"
|
||||||
"github.com/MedzikUser/go-utils/stats"
|
"github.com/MedzikUser/go-utils/stats"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"gitlab.com/gaming0skar123/go/pingbot/backend"
|
|
||||||
"gitlab.com/gaming0skar123/go/pingbot/config"
|
"gitlab.com/gaming0skar123/go/pingbot/config"
|
||||||
|
"gitlab.com/gaming0skar123/go/pingbot/ping"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Status(c *gin.Context) {
|
func Status(c *gin.Context) {
|
||||||
|
@ -19,20 +19,20 @@ func Status(c *gin.Context) {
|
||||||
cpu, err := stats.CPU()
|
cpu, err := stats.CPU()
|
||||||
common.CheckErr(err, "cpu stat")
|
common.CheckErr(err, "cpu stat")
|
||||||
|
|
||||||
var ping json
|
var p json
|
||||||
|
|
||||||
if config.Toml.Backend.Enabled {
|
if config.Toml.Backend.Enabled {
|
||||||
ping = json{
|
p = json{
|
||||||
"all": backend.Status.Error + backend.Status.Success,
|
"all": ping.Status.Error + ping.Status.Success,
|
||||||
"success": backend.Status.Success,
|
"success": ping.Status.Success,
|
||||||
"err": backend.Status.Error,
|
"err": ping.Status.Error,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ping = nil
|
p = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSON(http.StatusOK, json{
|
c.JSON(http.StatusOK, json{
|
||||||
"ping": ping,
|
"ping": p,
|
||||||
"sys": json{
|
"sys": json{
|
||||||
"pid": cpu.PID,
|
"pid": cpu.PID,
|
||||||
"os": runtime.GOOS,
|
"os": runtime.GOOS,
|
||||||
|
|
Loading…
Reference in a new issue