-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
54 lines (46 loc) · 1.04 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
46
47
48
49
50
51
52
53
54
package main
import (
"os"
"time"
"github.com/dm03514/wait-for/cmd"
log "github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
func init() {
// Log as JSON instead of the default ASCII formatter.
log.SetFormatter(&log.JSONFormatter{})
// Output to stdout instead of the default stderr
// Can be any io.Writer, see below for File example
log.SetOutput(os.Stdout)
// Only log the warning severity or above.
log.SetLevel(log.DebugLevel)
}
func main() {
app := cli.NewApp()
app.Name = "wait-for"
app.Usage = "wait for a service to become available"
app.Commands = []cli.Command{
cmd.HTTPCommand,
cmd.MySQLCommand,
cmd.NetCommand,
cmd.PostgresCommand,
cmd.RedisCommand,
}
app.Flags = []cli.Flag{
cli.DurationFlag{
Name: "timeout, t",
Value: time.Minute * 5,
Usage: "duration to wait until marking as failure and returning",
},
cli.DurationFlag{
Name: "poll-interval, pi",
Value: time.Millisecond * 100,
Usage: "interval",
},
}
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
os.Exit(1)
}
}