Files
micromdm/app/app.go
Victor Vrantchan 2751a79c86 refactor package main (#49)
move the contents of main.go into app package.
scaffold a CLI subcommands package. 
add a version package and add /_version handler to print detailed version info.
2016-11-13 15:50:36 -05:00

40 lines
939 B
Go

// Package app sets up and manages the MicroMDM server application which
// is composed of multiple independent components such as datastores and
// services.
package app
import "github.com/go-kit/kit/log"
// exit status
const (
success int = iota
badReturn // general errors
badInput // issue with CLI input
)
// Main is MicroMDM's main() function. Main parses the CLI options given
// by the user and sets up an HTTP service for all the services built into
// MicroMDM.
func Main(logger log.Logger) (status int, err error) {
config, err := loadConfig()
if err != nil {
return badInput, err
}
sm, err := setupServices(config, logger)
if err != nil {
return badReturn, err
}
err = serveHTTP(
logger,
makeHTTPHandler(logger, sm),
config.TLS.Enabled,
config.Server.ListenURL,
config.TLS.PrivateKeyPath,
config.TLS.CertificatePath,
)
if err != nil {
return badReturn, err
}
return success, nil
}