示例#1
0
文件: main.go 项目: drhurd/Seaport
func runNginxServer() {
	routes := makeRouteMap(docker.ListContainers())

	// Use nginx to forward
	file, err := os.Create(*nginxFile)
	if err != nil {
		log.Fatal("Couldn't open nginx file: ", err)
	}

	nginx.WriteConfigFile(file, routes, nginx.Config{ServerName: "localhost"})

	if getNginxStatus() {
		cmd := nginx.StopCommand()

		err := cmd.Run()
		if err != nil {
			log.Fatal("Couldn't stop nginx: ", err)
		}
	}

	cmd := nginx.StartCommand(*nginxFile)
	err = cmd.Run()
	if err != nil {
		log.Fatal("Couldn't start nginx: ", err)
	}
}
示例#2
0
文件: main.go 项目: drhurd/Seaport
func main() {
	// Configure the logger
	log.SetLevel(logLevel)

	// Parse the input
	kingpin.Parse()

	if *seaportMode {
		runSeaportServer(*serverPort)
	} else if *stop {
		cmd := nginx.StopCommand()

		err := cmd.Run()
		if err != nil {
			log.Fatal(err)
		}
	} else {
		runNginxServer()
	}
}