mirror of
https://github.com/nxshock/gron.git
synced 2024-11-27 03:41:00 +05:00
Add next launch time field
This commit is contained in:
parent
330c94f8e1
commit
c952ded006
@ -33,8 +33,10 @@ func handler(w http.ResponseWriter, r *http.Request) {
|
|||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
jobEntries := c.Entries()
|
jobEntries := c.Entries()
|
||||||
var jobs []*Job
|
var jobs []*Job
|
||||||
for _, v := range jobEntries {
|
for _, jobEntry := range jobEntries {
|
||||||
jobs = append(jobs, v.Job.(*Job))
|
job := jobEntry.Job.(*Job)
|
||||||
|
job.NextLaunch = jobEntry.Next.Format(config.TimeFormat)
|
||||||
|
jobs = append(jobs, job)
|
||||||
}
|
}
|
||||||
indexTemplate.ExecuteTemplate(buf, "index", jobs)
|
indexTemplate.ExecuteTemplate(buf, "index", jobs)
|
||||||
globalMutex.RUnlock()
|
globalMutex.RUnlock()
|
||||||
|
@ -193,6 +193,7 @@
|
|||||||
<th>Start time</th>
|
<th>Start time</th>
|
||||||
<th>Finish time</th>
|
<th>Finish time</th>
|
||||||
<th>Duration</th>
|
<th>Duration</th>
|
||||||
|
<th>Next launch</th>
|
||||||
<th>Last error</th>
|
<th>Last error</th>
|
||||||
</tr>
|
</tr>
|
||||||
{{range .}}<tr>
|
{{range .}}<tr>
|
||||||
@ -208,6 +209,7 @@
|
|||||||
<td>{{.LastStartTime}}</td>
|
<td>{{.LastStartTime}}</td>
|
||||||
<td>{{.LastEndTime}}</td>
|
<td>{{.LastEndTime}}</td>
|
||||||
<td align="right">{{.LastExecutionDuration}}</td>
|
<td align="right">{{.LastExecutionDuration}}</td>
|
||||||
|
<td>{{.NextLaunch}}</td>
|
||||||
<td class="smaller red">{{.LastError}}</td>
|
<td class="smaller red">{{.LastError}}</td>
|
||||||
</tr>{{end}}
|
</tr>{{end}}
|
||||||
</table>
|
</table>
|
||||||
|
35
job.go
35
job.go
@ -20,6 +20,24 @@ type JobConfig struct {
|
|||||||
Description string
|
Description string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Job struct {
|
||||||
|
Name string // from filename
|
||||||
|
|
||||||
|
Cron string // cron decription
|
||||||
|
Command string // command for execution
|
||||||
|
Params []string // command params
|
||||||
|
FileName string // short job name
|
||||||
|
Description string // job description
|
||||||
|
|
||||||
|
// Fields for stats
|
||||||
|
CurrentRunningCount int
|
||||||
|
LastStartTime string
|
||||||
|
LastEndTime string
|
||||||
|
LastExecutionDuration string
|
||||||
|
LastError string
|
||||||
|
NextLaunch string
|
||||||
|
}
|
||||||
|
|
||||||
var globalMutex sync.RWMutex
|
var globalMutex sync.RWMutex
|
||||||
|
|
||||||
func readJob(filePath string) (*Job, error) {
|
func readJob(filePath string) (*Job, error) {
|
||||||
@ -49,23 +67,6 @@ func (js *JobConfig) Write() {
|
|||||||
ioutil.WriteFile("job.conf", buf.Bytes(), 0644)
|
ioutil.WriteFile("job.conf", buf.Bytes(), 0644)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Job struct {
|
|
||||||
Name string // from filename
|
|
||||||
|
|
||||||
Cron string // cron decription
|
|
||||||
Command string // command for execution
|
|
||||||
Params []string // command params
|
|
||||||
FileName string // short job name
|
|
||||||
Description string // job description
|
|
||||||
|
|
||||||
// Fields for stats
|
|
||||||
CurrentRunningCount int
|
|
||||||
LastStartTime string
|
|
||||||
LastEndTime string
|
|
||||||
LastExecutionDuration string
|
|
||||||
LastError string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (j *Job) Run() {
|
func (j *Job) Run() {
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user