Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
Move all flag definitions from func init, to func main
Browse files Browse the repository at this point in the history
  • Loading branch information
sargun committed May 1, 2018
1 parent cf611f6 commit a1eed66
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
4 changes: 1 addition & 3 deletions cmd/titus-launchguard-server/main.go
Expand Up @@ -13,12 +13,10 @@ import (

var debug bool

func init() {
func main() {
flag.BoolVar(&debug, "debug", false, "Turn on debug logging")
flag.Parse()
}

func main() {
ctx := context.Background()
logsutil.MaybeSetupLoggerIfUnderSystemd()
if debug {
Expand Down
12 changes: 5 additions & 7 deletions cmd/titus-metadata-service/main.go
Expand Up @@ -23,13 +23,6 @@ var listenPort int
var debug bool
var backingMetadataServer string

func init() {
flag.StringVar(&backingMetadataServer, "backing-metadata-server", "http://169.254.169.254/", "The URI of the AWS metadata server you want to use")
flag.Int64Var(&listenerFd, "listener-fd", -1, "Use a specific fd for listening on")
flag.IntVar(&listenPort, "listener-port", defaultListeningPort, "Use specific port to listen on")
flag.BoolVar(&debug, "debug", false, "Set to true to debug logging")
}

/* Either returns a listener, or logs a fatal error */
func getListener() net.Listener {
if listenerFd != -1 && listenPort != defaultListeningPort {
Expand Down Expand Up @@ -71,6 +64,11 @@ func getEnv(key string) string {
}

func main() {
flag.StringVar(&backingMetadataServer, "backing-metadata-server", "http://169.254.169.254/", "The URI of the AWS metadata server you want to use")
flag.Int64Var(&listenerFd, "listener-fd", -1, "Use a specific fd for listening on")
flag.IntVar(&listenPort, "listener-port", defaultListeningPort, "Use specific port to listen on")
flag.BoolVar(&debug, "debug", false, "Set to true to debug logging")

flag.Parse()
if debug {
log.SetLevel(log.DebugLevel)
Expand Down
4 changes: 1 addition & 3 deletions cmd/titus-reaper/main.go
Expand Up @@ -13,13 +13,11 @@ import (
var dockerHost string
var debug bool

func init() {
func main() {
flag.StringVar(&dockerHost, "docker-host", "unix:///var/run/docker.sock", "Docker Daemon URI")
flag.BoolVar(&debug, "debug", false, "Turn on debug logging")
flag.Parse()
}

func main() {
logsutil.MaybeSetupLoggerIfUnderSystemd()
if debug {
log.SetLevel(log.DebugLevel)
Expand Down

0 comments on commit a1eed66

Please sign in to comment.