func main() { cf_debug_server.AddFlags(flag.CommandLine) cf_lager.AddFlags(flag.CommandLine) stackMap := stackPathMap{} supportedProviders := providers{} flag.Var(&stackMap, "preloadedRootFS", "List of preloaded RootFSes") flag.Var(&supportedProviders, "rootFSProvider", "List of RootFS providers") flag.Parse() cf_http.Initialize(*communicationTimeout) logger, reconfigurableSink := cf_lager.New(*sessionName) executorConfiguration := executorConfig() if !executorinit.ValidateExecutor(logger, executorConfiguration) { os.Exit(1) } initializeDropsonde(logger) if *cellID == "" { log.Fatalf("-cellID must be specified") } executorClient, executorMembers, err := executorinit.Initialize(logger, executorConfiguration) if err != nil { log.Fatalf("Failed to initialize executor: %s", err.Error()) } defer executorClient.Cleanup() if err := validateBBSAddress(); err != nil { logger.Fatal("invalid-bbs-address", err) } locketClient := initializeLocketClient(logger) clock := clock.NewClock() evacuatable, evacuationReporter, evacuationNotifier := evacuation_context.New() // only one outstanding operation per container is necessary queue := operationq.NewSlidingQueue(1) evacuator := evacuation.NewEvacuator( logger, clock, executorClient, evacuationNotifier, *cellID, *evacuationTimeout, *evacuationPollingInterval, ) bbsClient := initializeBBSClient(logger) httpServer, address := initializeServer(bbsClient, executorClient, evacuatable, evacuationReporter, logger, rep.StackPathMap(stackMap), supportedProviders) opGenerator := generator.New(*cellID, bbsClient, executorClient, evacuationReporter, uint64(evacuationTimeout.Seconds())) preloadedRootFSes := []string{} for k := range stackMap { preloadedRootFSes = append(preloadedRootFSes, k) } members := grouper.Members{ {"http_server", httpServer}, {"presence", initializeCellPresence(address, locketClient, executorClient, logger, supportedProviders, preloadedRootFSes)}, {"bulker", harmonizer.NewBulker(logger, *pollingInterval, *evacuationPollingInterval, evacuationNotifier, clock, opGenerator, queue)}, {"event-consumer", harmonizer.NewEventConsumer(logger, opGenerator, queue)}, {"evacuator", evacuator}, } members = append(executorMembers, members...) if dbgAddr := cf_debug_server.DebugAddress(flag.CommandLine); dbgAddr != "" { members = append(grouper.Members{ {"debug-server", cf_debug_server.Runner(dbgAddr, reconfigurableSink)}, }, members...) } group := grouper.NewOrdered(os.Interrupt, members) monitor := ifrit.Invoke(sigmon.New(group)) logger.Info("started", lager.Data{"cell-id": *cellID}) err = <-monitor.Wait() if err != nil { logger.Error("exited-with-failure", err) os.Exit(1) } logger.Info("exited") }
container := executor.Container{ Guid: containerGuid, Action: models.WrapAction(&models.RunAction{ Path: "sh", Args: []string{"-c", `[ "$(id -u)" -eq "0" ]`}, User: "******", }), } config := executorinit.DefaultConfiguration config.GardenNetwork = "tcp" config.GardenAddr = componentMaker.Addresses.GardenLinux config.AllowPrivileged = allowPrivileged logger := lagertest.NewTestLogger("test") executorClient, executorMembers, err := executorinit.Initialize(logger, config) Expect(err).NotTo(HaveOccurred()) runner = grouper.NewParallel(os.Kill, executorMembers) _, err = executorClient.AllocateContainers([]executor.Container{container}) Expect(err).NotTo(HaveOccurred()) err = executorClient.RunContainer(containerGuid) Expect(err).NotTo(HaveOccurred()) Eventually(func() executor.State { container, err := executorClient.GetContainer(containerGuid) if err != nil { return executor.StateInvalid }