Remove most global variables from main.go

This takes advantage of the newly created parseCommandLineOptions()
function and makes it work so that it now returns a nice struct of
options rather than relying on global variables.

There are a few global variables left, but they will take a bit more
refactoring in order to be removed, so it'll happen in later commits.
This commit is contained in:
Anderson Mesquita
2015-12-17 17:40:46 -05:00
parent 2cdfa59fbe
commit d10e81fb3d
2 changed files with 93 additions and 79 deletions

View File

@@ -34,13 +34,14 @@ const (
logFileMaxOpenTime = time.Minute
)
func monitorMain() {
func monitorMain(runtimeOptions RuntimeOptions) {
os.Setenv("STNORESTART", "yes")
os.Setenv("STMONITORED", "yes")
l.SetPrefix("[monitor] ")
var dst io.Writer = os.Stdout
logFile := runtimeOptions.logFile
if logFile != "-" {
var fileDst io.Writer = newAutoclosedFile(logFile, logFileAutoCloseDelay, logFileMaxOpenTime)