mirror of
https://github.com/tgdrive/teldrive.git
synced 2025-01-08 08:10:05 +08:00
chore: update stataviz monitoring
This commit is contained in:
parent
2eaceea53e
commit
c5b9c99005
6 changed files with 21 additions and 3 deletions
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
|
@ -30,10 +30,10 @@ jobs:
|
|||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Run GoReleaser
|
||||
uses: goreleaser/goreleaser-action@v6
|
||||
uses: goreleaser/goreleaser-action@v5
|
||||
with:
|
||||
distribution: goreleaser
|
||||
version: "~> v2"
|
||||
version: latest
|
||||
args: release --clean
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
@ -1,4 +1,3 @@
|
|||
version: 2
|
||||
project_name: teldrive
|
||||
env:
|
||||
- GO111MODULE=on
|
||||
|
|
15
cmd/run.go
15
cmd/run.go
|
@ -11,6 +11,7 @@ import (
|
|||
"time"
|
||||
"unicode"
|
||||
|
||||
"github.com/arl/statsviz"
|
||||
"github.com/divyam234/teldrive/api"
|
||||
"github.com/divyam234/teldrive/internal/config"
|
||||
"github.com/divyam234/teldrive/internal/database"
|
||||
|
@ -54,6 +55,7 @@ func NewRun() *cobra.Command {
|
|||
runCmd.Flags().IntVarP(&config.Server.Port, "server-port", "p", 8080, "Server port")
|
||||
duration.DurationVar(runCmd.Flags(), &config.Server.GracefulShutdown, "server-graceful-shutdown", 15*time.Second, "Server graceful shutdown timeout")
|
||||
runCmd.Flags().BoolVar(&config.Server.EnablePprof, "server-enable-pprof", false, "Enable Pprof Profiling")
|
||||
runCmd.Flags().BoolVar(&config.Server.EnableStatsviz, "server-enable-statsviz", false, "Enable Statsviz Monitoring")
|
||||
|
||||
runCmd.Flags().BoolVar(&config.CronJobs.Enable, "cronjobs-enable", true, "Run cron jobs")
|
||||
|
||||
|
@ -230,6 +232,19 @@ func initApp(lc fx.Lifecycle, cfg *config.Config, c *controller.Controller) *gin
|
|||
pprof.Register(r)
|
||||
}
|
||||
|
||||
if cfg.Server.EnableStatsviz {
|
||||
srv, _ := statsviz.NewServer()
|
||||
ws := srv.Ws()
|
||||
index := srv.Index()
|
||||
r.GET("/debug/statsviz/*filepath", func(context *gin.Context) {
|
||||
if context.Param("filepath") == "/ws" {
|
||||
ws(context.Writer, context.Request)
|
||||
return
|
||||
}
|
||||
index(context.Writer, context.Request)
|
||||
})
|
||||
}
|
||||
|
||||
r.Use(gin.Recovery())
|
||||
|
||||
r.Use(ginzap.GinzapWithConfig(logging.DefaultLogger().Desugar(), &ginzap.Config{
|
||||
|
|
1
go.mod
1
go.mod
|
@ -33,6 +33,7 @@ require (
|
|||
|
||||
require (
|
||||
filippo.io/edwards25519 v1.1.0 // indirect
|
||||
github.com/arl/statsviz v0.6.0 // indirect
|
||||
github.com/bytedance/sonic/loader v0.1.1 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/cloudwego/base64x v0.1.4 // indirect
|
||||
|
|
2
go.sum
2
go.sum
|
@ -4,6 +4,8 @@ github.com/DATA-DOG/go-sqlmock v1.5.2 h1:OcvFkGmslmlZibjAjaHm3L//6LiuBgolP7Oputl
|
|||
github.com/DATA-DOG/go-sqlmock v1.5.2/go.mod h1:88MAG/4G7SMwSE3CeA0ZKzrT5CiOU3OJ+JlNzwDqpNU=
|
||||
github.com/WinterYukky/gorm-extra-clause-plugin v0.2.1 h1:G0e4eFRrh3WdM1I3EKKidV2yF5J09uRIJlKYxt6zNR4=
|
||||
github.com/WinterYukky/gorm-extra-clause-plugin v0.2.1/go.mod h1:qAN5KRJJTCM49X2wUHZAVB3rfvO8A8L0ISd/uB1WM5s=
|
||||
github.com/arl/statsviz v0.6.0 h1:jbW1QJkEYQkufd//4NDYRSNBpwJNrdzPahF7ZmoGdyE=
|
||||
github.com/arl/statsviz v0.6.0/go.mod h1:0toboo+YGSUXDaS4g1D5TVS4dXs7S7YYT5J/qnW2h8s=
|
||||
github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0=
|
||||
github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4=
|
||||
github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM=
|
||||
|
|
|
@ -17,6 +17,7 @@ type ServerConfig struct {
|
|||
Port int
|
||||
GracefulShutdown time.Duration
|
||||
EnablePprof bool
|
||||
EnableStatsviz bool
|
||||
}
|
||||
|
||||
type CronJobConfig struct {
|
||||
|
|
Loading…
Reference in a new issue