diff --git a/httpserver.go b/httpserver.go index 04d3f9b..abd1ec7 100644 --- a/httpserver.go +++ b/httpserver.go @@ -33,8 +33,10 @@ func handler(w http.ResponseWriter, r *http.Request) { buf := new(bytes.Buffer) jobEntries := c.Entries() var jobs []*Job - for _, v := range jobEntries { - jobs = append(jobs, v.Job.(*Job)) + for _, jobEntry := range jobEntries { + job := jobEntry.Job.(*Job) + job.NextLaunch = jobEntry.Next.Format(config.TimeFormat) + jobs = append(jobs, job) } indexTemplate.ExecuteTemplate(buf, "index", jobs) globalMutex.RUnlock() diff --git a/index.htm b/index.htm index 83cc2e7..2ccfbad 100644 --- a/index.htm +++ b/index.htm @@ -193,6 +193,7 @@ Start time Finish time Duration + Next launch Last error {{range .}} @@ -208,6 +209,7 @@ {{.LastStartTime}} {{.LastEndTime}} {{.LastExecutionDuration}} + {{.NextLaunch}} {{.LastError}} {{end}} diff --git a/job.go b/job.go index c8de416..0abcf48 100644 --- a/job.go +++ b/job.go @@ -20,6 +20,24 @@ type JobConfig struct { 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 func readJob(filePath string) (*Job, error) { @@ -49,23 +67,6 @@ func (js *JobConfig) Write() { 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() { startTime := time.Now()