-
Notifications
You must be signed in to change notification settings - Fork 0
/
ingest_bucket_reader.go
50 lines (41 loc) · 1.15 KB
/
ingest_bucket_reader.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"flag"
"fmt"
"os"
"github.com/APTrust/preservation-services/util/cli"
"github.com/APTrust/preservation-services/workers"
)
func main() {
help := false
runOnce := false
flag.BoolVar(&help, "help", false, "Print help message")
flag.BoolVar(&runOnce, "run-once", false, "Run once and exit (cron mode instead of server mode)")
flag.Parse()
if help {
printHelp()
os.Exit(0)
}
reader := workers.NewIngestBucketReader()
if runOnce {
reader.RunOnce()
} else {
stopChan := make(chan struct{})
reader.RunAsService()
<-stopChan
}
}
func printHelp() {
message := `
ingest_bucket_reader scans depositors' receiving buckets for new bags to
ingest. It creates a new WorkItem for each new bag and queues the WorkItem
ID in the NSQ ingest pre-fetch topic.
When running as a service (i.e. withouth --run-once), this relies on the
config setting INGEST_BUCKET_READER_INTERVAL to determine how long to wait
after the end of one scan before beginning the next.
You can also run the bucket reader as a one-off job with the --run-once
flag. It will perform one scan and then exit.
`
fmt.Println(message)
fmt.Println(cli.EnvMessage)
}