-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
45 lines (40 loc) · 1.16 KB
/
main.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 (
"context"
"flag"
"os"
"os/signal"
"syscall"
)
func main() {
// TODO: add flags for each of the options and pass to newHeyFil
httpIndexerEndpoint := flag.String("httpIndexerEndpoint", "https://cid.contact", "The HTTP IPNI endpoint to which announcements are made.")
maxConcurrentChecks := flag.Int("maxConcurrentChecks", 10, "The maximum number of concurrent checks.")
storePath := flag.String("storePath", "", "The directory to use for storing the discovered SP information.")
token := flag.String("token", "", "A bearer token to pass for auth to the filecoin api endpoint.")
flag.Parse()
hf, err := newHeyFil(
WithHttpIndexerEndpoint(*httpIndexerEndpoint),
WithMaxConcurrentChecks(*maxConcurrentChecks),
WithStorePath(*storePath),
WithFileCoinAPIToken(*token),
)
if err != nil {
panic(err)
}
ctx, cancel := context.WithCancel(context.Background())
if err := hf.Start(ctx); err != nil {
panic(err)
}
defer func() {
cancel()
_ = hf.Shutdown(context.Background())
}()
exit := make(chan os.Signal, 1)
signal.Notify(exit, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
go func() {
<-exit
cancel()
}()
<-ctx.Done()
}