File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -19,9 +19,17 @@ import (
1919 "code.gitea.io/gitea/modules/process"
2020 "code.gitea.io/gitea/modules/setting"
2121 "code.gitea.io/gitea/modules/translation"
22+ "github.com/prometheus/client_golang/prometheus"
23+ "github.com/prometheus/client_golang/prometheus/promauto"
2224)
2325
2426var (
27+ cronInflight = promauto .NewGauge (prometheus.GaugeOpts {
28+ Namespace : "gitea" ,
29+ Subsystem : "cron" ,
30+ Name : "active_tasks" ,
31+ Help : "Number of running cron tasks" ,
32+ })
2533 lock = sync.Mutex {}
2634 started = false
2735 tasks = []* Task {}
@@ -86,6 +94,8 @@ func (t *Task) RunWithUser(doer *user_model.User, config Config) {
8694 taskStatusTable .Stop (t .Name )
8795 }()
8896 graceful .GetManager ().RunWithShutdownContext (func (baseCtx context.Context ) {
97+ cronInflight .Inc ()
98+ defer cronInflight .Dec ()
8999 defer func () {
90100 if err := recover (); err != nil {
91101 // Recover a panic within the execution of the task.
You can’t perform that action at this time.
0 commit comments