feat: use daemon flag to toggle scheduler/standalone
All checks were successful
build / build (push) Successful in 1m22s

This commit is contained in:
Viktor Varland 2025-04-14 12:49:37 +02:00
parent f1195adc5c
commit 08779a5941
Signed by: varl
GPG key ID: 7459F0B410115EE8
4 changed files with 11 additions and 2 deletions

View file

@ -32,6 +32,7 @@ RUN mkdir -p /data/vids
COPY <<-EOT /data/config.toml COPY <<-EOT /data/config.toml
dry_run = false dry_run = false
out_dir = "/data/vids" out_dir = "/data/vids"
daemon = true
[provider] [provider]
[provider.youtube] [provider.youtube]

View file

@ -72,6 +72,7 @@ Full `config.toml`:
```toml ```toml
dry_run = true # set to `false` for real run dry_run = true # set to `false` for real run
out_dir = "./vids" # path to archive vids out_dir = "./vids" # path to archive vids
daemon = true # true to run scheduler, false to run once
[provider] [provider]
[provider.youtube] [provider.youtube]

View file

@ -25,6 +25,7 @@ type Config struct {
Out_dir string Out_dir string
Provider map[string]Provider Provider map[string]Provider
Dry_run bool Dry_run bool
Daemon bool
} }
func Load(filepath string) (Config, error) { func Load(filepath string) (Config, error) {

10
main.go
View file

@ -58,6 +58,12 @@ func main() {
panic(err) panic(err)
} }
s := scheduler.Scheduler{} if cfg.Daemon {
s.Start(run, cfg) log.Println("running with scheduler")
s := scheduler.Scheduler{}
s.Start(run, cfg)
} else {
log.Println("running standalone")
run(cfg)
}
} }