Ejemplo n.º 1
0
func main() {
	defaultListNetwork := "unix"
	defaultListAddr := "/tmp/garden.sock"
	if os.Getenv("PORT") != "" {
		defaultListNetwork = "tcp"
		defaultListAddr = "0.0.0.0:" + os.Getenv("PORT")
	}
	var listenNetwork = flag.String(
		"listenNetwork",
		defaultListNetwork,
		"how to listen on the address (unix, tcp, etc.)",
	)
	var listenAddr = flag.String(
		"listenAddr",
		defaultListAddr,
		"address to listen on",
	)
	cf_lager.AddFlags(flag.CommandLine)
	flag.Parse()

	logger, _ := cf_lager.New("garden-windows")

	initializeDropsonde(logger)

	url, err := url.Parse(*containerizerURL)
	if err != nil {
		logger.Fatal("Could not parse containerizer url", err, lager.Data{
			"containerizerURL": containerizerURL,
		})
	}
	client := dotnet.NewClient(logger, url)
	netBackend, err := backend.NewDotNetBackend(client, logger, *containerGraceTime)
	if err != nil {
		logger.Fatal("Server Failed to Start", err)
		os.Exit(1)
	}

	gardenServer := server.New(*listenNetwork, *listenAddr, *containerGraceTime, netBackend, logger)
	err = gardenServer.Start()
	if err != nil {
		logger.Fatal("Server Failed to Start", err)
		os.Exit(1)
	}

	logger.Info("started", lager.Data{
		"network": *listenNetwork,
		"addr":    *listenAddr,
	})

	signals := make(chan os.Signal, 1)

	go func() {
		<-signals
		gardenServer.Stop()
		os.Exit(0)
	}()

	signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM, syscall.SIGHUP)
	select {}
}
	return &n
}

var _ = Describe("container", func() {
	var server *ghttp.Server
	var container garden.Container
	var logger *lagertest.TestLogger
	var client *dotnet.Client
	var externalIP string

	BeforeEach(func() {
		server = ghttp.NewServer()
		externalIP = "10.11.12.13"
		logger = lagertest.NewTestLogger("container")
		serverUri, _ := url.Parse(server.URL())
		client = dotnet.NewClient(logger, serverUri)
		container = netContainer.NewContainer(client, "containerhandle", logger)
	})

	AfterEach(func() {
		//shut down the server between tests
		if server.HTTPTestServer != nil {
			server.Close()
		}
	})

	Describe("Info", func() {
		Describe("for a valid handle", func() {
			BeforeEach(func() {
				server.AppendHandlers(
					ghttp.CombineHandlers(
Ejemplo n.º 3
0
)

var _ = Describe("process", func() {
	var proc DotNetProcess
	var client *dotnet.Client

	type IntErrorTuple struct {
		exitStatus int
		err        error
	}

	BeforeEach(func() {
		logger := lagertest.NewTestLogger("process")
		baseUrl, err := url.Parse("http://example.com")
		Expect(err).NotTo(HaveOccurred())
		client = dotnet.NewClient(logger, baseUrl)
		proc = NewDotNetProcess("cHandle", client)
	})

	Describe("Id", func() {
		It("returns the pid", func() {
			proc = DotNetProcess{Pid: "9876"}
			Expect(proc.ID()).To(Equal("9876"))
		})
	})

	Describe("Wait", func() {
		var exitStatusChannel chan IntErrorTuple
		BeforeEach(func() {
			exitStatusChannel = make(chan IntErrorTuple, 0)
			go func() {
Ejemplo n.º 4
0
	"github.com/onsi/gomega/ghttp"
)

var _ = Describe("backend", func() {
	var server *ghttp.Server
	var dotNetBackend garden.Backend
	var serverUri *url.URL
	var logger *lagertest.TestLogger
	var client *dotnet.Client

	BeforeEach(func() {
		server = ghttp.NewServer()
		logger = lagertest.NewTestLogger("backend")
		serverUri, _ = url.Parse(server.URL())
		client = dotnet.NewClient(logger, serverUri)
		graceTime := time.Minute
		dotNetBackend, _ = backend.NewDotNetBackend(client, logger, graceTime)
	})

	AfterEach(func() {
		//shut down the server between tests
		if server.HTTPTestServer != nil {
			server.Close()
		}
	})

	Describe("Client", func() {
		Context("when there is an timeout making the http connection", func() {
			BeforeEach(func() {
				client.SetHttpTimeout(100 * time.Millisecond)