func main() { var port = flag.Int("port", -1, "Port to listen on") var unsecureMode = flag.Bool("unsecure", false, "Boot in unsecure mode") flag.Parse() if *port == -1 { fmt.Println("Must specify a -port argument") return } var coreConfig *roll.CoreConfig if *unsecureMode == true { fmt.Println(unsecureBanner) if dbutil.UseMariaDB() { log.Info("Using maria db") coreConfig = rollsvcs.MariaDBUnsecureConfig() } else { log.Info("Using dynamo db") coreConfig = rollsvcs.DefaultUnsecureConfig() } } else { if dbutil.UseMariaDB() { log.Info("Using maria db") coreConfig = rollsvcs.MariaDBSecureConfig() } else { log.Info("Using dynamo db") coreConfig = rollsvcs.DefaultConfig() } } rollsvcs.RunRoll(*port, coreConfig) }
func RunVaultAndRoll() chan bool { //Grab the environment dockerHost, dockerCertPath := dockerutil.ReadDockerEnv() // Init the client log.Info("Create docker client") docker, _ := dockerclient.NewDockerClient(dockerHost, dockerutil.BuildDockerTLSConfig(dockerCertPath)) containerName, token := runVault(docker) log.Printf("export VAULT_TOKEN=%s\n", token) log.Info("export VAULT_ADDR=http://localhost:8200") //Set up interrupt signal handler signalChan := make(chan os.Signal, 1) shutdownDone := make(chan bool) signal.Notify(signalChan, os.Interrupt) //Run the server go func() { os.Setenv("VAULT_TOKEN", token) os.Setenv("VAULT_ADDR", "http://localhost:8200") coreConfig := rollsvcs.DefaultUnsecureConfig() rollsvcs.RunRoll(3000, coreConfig) }() //Handler shutdown go func() { for _ = range signalChan { fmt.Println("\nReceived an interrupt, stopping roll...") stopVaultOnShutdown(containerName, docker) shutdownDone <- true } }() return shutdownDone }
func createUnsecureDynamoDBConfig() *roll.CoreConfig { log.Info(unsecureBanner) return rollsvcs.DefaultUnsecureConfig() }