Added a main loop on a timed interval
This commit is contained in:
parent
02dfc7c291
commit
cf854a91f0
10
adept.go
10
adept.go
@ -1,6 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
|
||||||
"git.metaunix.net/BitGoblin/adept/config"
|
"git.metaunix.net/BitGoblin/adept/config"
|
||||||
@ -12,7 +14,10 @@ func main() {
|
|||||||
|
|
||||||
r := transcoder.NewRepository(viper.GetString("transcoder.repository"))
|
r := transcoder.NewRepository(viper.GetString("transcoder.repository"))
|
||||||
|
|
||||||
|
// main program loop - runs infinitely until externally terminated
|
||||||
|
for {
|
||||||
ingestFiles := r.SearchIngest()
|
ingestFiles := r.SearchIngest()
|
||||||
|
|
||||||
for _, i := range ingestFiles {
|
for _, i := range ingestFiles {
|
||||||
// archive file
|
// archive file
|
||||||
r.ArchiveFile(i.Name())
|
r.ArchiveFile(i.Name())
|
||||||
@ -21,4 +26,9 @@ func main() {
|
|||||||
// clean up source file
|
// clean up source file
|
||||||
r.CleanupFile(i.Name())
|
r.CleanupFile(i.Name())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sleep for X minutes - specified in the adept.toml config file
|
||||||
|
interval := viper.GetInt("transcoder.interval")
|
||||||
|
time.Sleep(time.Duration(interval) * time.Minute)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,8 @@ func NewRepository(path string) *Repository {
|
|||||||
func (r *Repository) SearchIngest() []os.FileInfo {
|
func (r *Repository) SearchIngest() []os.FileInfo {
|
||||||
ingestPath := filepath.Join(r.basePath, "ingest")
|
ingestPath := filepath.Join(r.basePath, "ingest")
|
||||||
|
|
||||||
|
log.Printf("Searching ingest directory for files to transcode...")
|
||||||
|
|
||||||
ingestDir, err := os.Open(ingestPath)
|
ingestDir, err := os.Open(ingestPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error opening ingest directory: %s", err)
|
log.Fatalf("Error opening ingest directory: %s", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user