-
Notifications
You must be signed in to change notification settings - Fork 0
/
ingest_cleanup.go
45 lines (39 loc) · 1.17 KB
/
ingest_cleanup.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
package main
import (
"fmt"
"os"
"github.com/APTrust/preservation-services/util/cli"
"github.com/APTrust/preservation-services/workers"
)
func main() {
cli.Init()
opts := cli.ParseOpts()
if opts.PrintHelp {
printHelp()
cli.PrintDefaults()
os.Exit(0)
}
// If anything goes wrong, this panics.
// Otherwise, it starts handling NSQ messages immediately.
worker := workers.NewIngestCleanup(
opts.ChannelBufferSize,
opts.NumWorkers,
opts.MaxAttempts,
)
// This channel blocks until we get an interrupt,
// so our program does not exit without Control-C
// or other kill signal.
<-worker.NSQConsumer.StopChan
}
func printHelp() {
message := `
ingest_cleanup cleans up all processing data after completion of an ingest.
This includes files in the staging area, metadata collected in Redis, and
the original tar file in the depisitor's receiving bucket. In some cases,
ingest_cleanup may not delete the original bag from the receiving bucket.
This happens, for example, when the system thinks the tar file in receiving
is no longer the same as the one it ingested, or when errors other than
invalid bag errors occur.`
fmt.Println(message)
fmt.Println(cli.EnvMessage)
}