func NewBackgroundHeartbeat(natsClient diegonats.NATSClient, natsAddress, natsUsername, natsPassword string, logger lager.Logger, registration RegistryMessage) ifrit.RunFunc {
	return func(signals <-chan os.Signal, ready chan<- struct{}) error {
		restarter := restart.Restarter{
			Runner: newBackgroundGroup(natsClient, natsAddress, natsUsername, natsPassword, logger, registration),
			Load: func(runner ifrit.Runner, err error) ifrit.Runner {
				return newBackgroundGroup(natsClient, natsAddress, natsUsername, natsPassword, logger, registration)
			},
		}
		// don't wait, start this thing in the background
		close(ready)
		return restarter.Run(signals, make(chan struct{}))
	}
}
Beispiel #2
0
package restart_test

import (
	"os"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/tedsuo/ifrit"
	"github.com/tedsuo/ifrit/fake_runner"
	"github.com/tedsuo/ifrit/restart"
)

var _ = Describe("Restart", func() {
	var testRunner *fake_runner.TestRunner
	var restarter restart.Restarter
	var process ifrit.Process

	BeforeEach(func() {
		testRunner = fake_runner.NewTestRunner()
		restarter = restart.Restarter{
			Runner: testRunner,
			Load: func(runner ifrit.Runner, err error) ifrit.Runner {
				return nil
			},
		}
	})

	JustBeforeEach(func() {
		process = ifrit.Background(restarter)
	})