mirror of
https://github.com/komari-monitor/komari.git
synced 2026-11-24 09:05:49 +00:00
Replace ad-hoc ticker loops with named cron-based scheduled tasks for cleanup, minute reporting, and expiration checks. Add scheduler shutdown handling and log errors when schedules fail to reload or register. Update imports to use the relocated pkg/config package across affected code.
42 lines
975 B
Go
42 lines
975 B
Go
package public
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/komari-monitor/komari/database/tasks"
|
|
"github.com/komari-monitor/komari/web/api"
|
|
)
|
|
|
|
// PublicPingTask 是对外暴露的延迟监测任务信息。
|
|
type PublicPingTask struct {
|
|
Id uint `json:"id"`
|
|
Name string `json:"name"`
|
|
Clients []string `json:"clients"`
|
|
DefaultOn bool `json:"default_on"`
|
|
Type string `json:"type"`
|
|
Interval int `json:"interval"`
|
|
}
|
|
|
|
func GetPublicPingTasks(c *gin.Context) {
|
|
tasks, err := tasks.GetAllPingTasks()
|
|
if err != nil {
|
|
api.RespondError(c, http.StatusInternalServerError, err.Error())
|
|
return
|
|
}
|
|
|
|
publicTasks := make([]PublicPingTask, len(tasks))
|
|
for i, task := range tasks {
|
|
publicTasks[i] = PublicPingTask{
|
|
Id: task.Id,
|
|
Name: task.Name,
|
|
Clients: task.Clients,
|
|
DefaultOn: task.DefaultOn,
|
|
Type: task.Type,
|
|
Interval: task.Interval,
|
|
}
|
|
}
|
|
|
|
api.RespondSuccess(c, publicTasks)
|
|
}
|