Example #1
0
func NewCliApp() *cli.App {
	config := config.New(persister.NewFilePersister(config_helpers.ConfigFileLocation(ltcConfigRoot())))

	signalChan := make(chan os.Signal)
	signal.Notify(signalChan, os.Interrupt)
	exitHandler := exit_handler.New(signalChan, os.Exit)
	go exitHandler.Run()

	targetVerifier := target_verifier.New(receptor_client_factory.MakeReceptorClient)
	app := cli_app_factory.MakeCliApp(latticeVersion, ltcConfigRoot(), exitHandler, config, logger(), targetVerifier, os.Stdout)
	return app
}
Example #2
0
func NewCliApp() *cli.App {
	config := config.New(persister.NewFilePersister(config_helpers.ConfigFileLocation(ltcConfigRoot())))

	signalChan := make(chan os.Signal)
	signal.Notify(signalChan, os.Interrupt)
	exitHandler := exit_handler.New(signalChan, os.Exit)
	go exitHandler.Run()

	receptorClientCreator := receptor_client.ProxyAwareCreator{}

	return cli_app_factory.MakeCliApp(
		diegoVersion,
		latticeVersion,
		ltcConfigRoot(),
		exitHandler,
		config,
		logger(),
		receptorClientCreator,
		target_verifier.New(receptorClientCreator),
		os.Stdout,
	)
}
Example #3
0
func NewCliApp() *cli.App {
	config := config.New(persister.NewFilePersister(config_helpers.ConfigFileLocation(ltcConfigRoot())))

	signalChan := make(chan os.Signal)
	signal.Notify(signalChan, os.Interrupt)
	exitHandler := exit_handler.New(signalChan, os.Exit)
	go exitHandler.Run()

	targetVerifier := target_verifier.New(func(target string) receptor.Client {
		return receptor.NewClient(target)
	})

	return cli_app_factory.MakeCliApp(
		diegoVersion,
		latticeVersion,
		ltcConfigRoot(),
		exitHandler,
		config,
		logger(),
		targetVerifier,
		os.Stdout,
	)
}
	var (
		buffer      *gbytes.Buffer
		exitFunc    func(int)
		signalChan  chan os.Signal
		exitHandler exit_handler.ExitHandler
	)

	BeforeEach(func() {
		buffer = gbytes.NewBuffer()

		exitFunc = func(code int) {
			buffer.Write([]byte(fmt.Sprintf("Exit-Code=%d", code)))
		}

		signalChan = make(chan os.Signal)
		exitHandler = exit_handler.New(signalChan, exitFunc)
		go exitHandler.Run()

		exitHandler.OnExit(func() {
			buffer.Write([]byte("handler1 "))
		})

		exitHandler.OnExit(func() {
			buffer.Write([]byte("handler2 "))
		})
	})

	Context("Signals", func() {
		It("Executes exit handlers on os.Interupts", func() {
			signalChan <- os.Interrupt
			Eventually(buffer).Should(gbytes.Say("handler1 handler2 Exit-Code=160"))