fix timestamp issues
This commit is contained in:
parent
7f793dc75c
commit
235329774f
3 changed files with 4 additions and 10 deletions
|
@ -1 +0,0 @@
|
|||
package api
|
12
main.go
12
main.go
|
@ -7,7 +7,6 @@ import (
|
|||
"github.com/Garionion/ffmpeg-playout/api"
|
||||
"github.com/Garionion/ffmpeg-playout/playout"
|
||||
"github.com/Garionion/ffmpeg-playout/store"
|
||||
"github.com/golang/protobuf/ptypes"
|
||||
"github.com/ilyakaznacheev/cleanenv"
|
||||
"google.golang.org/grpc"
|
||||
"log"
|
||||
|
@ -31,9 +30,8 @@ type Config struct {
|
|||
PrometheusPushGateway string `yaml:"prometheusPushGateway"`
|
||||
}
|
||||
|
||||
func (g *server) schedulePlayout(ctx context.Context, job *api.Job) (*api.ScheduledJob, error) {
|
||||
func (g *server) SchedulePlayout(ctx context.Context, job *api.Job) (*api.ScheduledJob, error) {
|
||||
var p *playout.Job
|
||||
var err error
|
||||
|
||||
if job.Source == "" {
|
||||
return nil, errors.New("Got Empty Source. I can't play »Nothing«")
|
||||
|
@ -54,14 +52,10 @@ func (g *server) schedulePlayout(ctx context.Context, job *api.Job) (*api.Schedu
|
|||
p.ID = job.ID
|
||||
p.Source = job.Source
|
||||
p.Version = job.Version
|
||||
p.StartAt, err = ptypes.Timestamp(job.StartAt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
p.StartAt = job.StartAt.AsTime()
|
||||
p.StopAt = job.StopAt.AsTime()
|
||||
if p.StopAt.IsZero() {
|
||||
p.StopAt = p.StartAt.Add(g.Store.DefaultDuration)
|
||||
} else {
|
||||
p.StopAt, err = ptypes.Timestamp(job.StartAt)
|
||||
}
|
||||
|
||||
if playoutExists {
|
||||
|
|
|
@ -95,6 +95,7 @@ func (p *Job) Playout(cfg *Config) {
|
|||
playoutScript := path.Join(cfg.PlayoutScriptPath, cfg.PlayoutScript)
|
||||
for {
|
||||
log.Printf("Start Playout for %v", p.ID)
|
||||
log.Println(p.StartAt)
|
||||
log.Println(p.StopAt)
|
||||
log.Println(time.Until(p.StopAt))
|
||||
cmd := exec.Command(playoutScript, //nolint:gosec
|
||||
|
|
Loading…
Reference in a new issue