示例#1
0
func main() {
	wg := &sync.WaitGroup{}

	notificationBackend := backend.GetBackend(applicationConfig.BackendName)
	err := notificationBackend.Initialize(applicationConfig.BackendOpenString)
	if err != nil {
		logger.WithField("error", err).Panic("cannot initialize backend")
	}

	notificationBackend.Start(wg)
	defer func() {
		notificationBackend.Shutdown()
		wg.Wait()
	}()

	notificationBackend.BlockUntilReady()
	receiverApp := webreceiver.NewApp(notificationBackend, applicationConfig.Receiver)

	receiverServer := &http.Server{
		Addr:    fmt.Sprintf("%s:%d", applicationConfig.Receiver.ListenHost, applicationConfig.Receiver.ListenPort),
		Handler: receiverApp,
	}

	gracehttp.Serve(receiverServer)
}
示例#2
0
func (s *WebReceiverAppSuite) SetUpTest(c *C) {
	s.notifier = testhelpers.NewTestNotifier()
	backend.ClearAllNotifiers()
	backend.RegisterNotifier(s.notifier)

	s.backend = backend.GetBackend(sqlite_backend.BackendName).(*sqlite_backend.SQLiteNotificationBackend)
	err := s.backend.Initialize(":memory:,../sqlite_backend/test_config/standard.conf.json")
	c.Assert(err, IsNil)

	// TODO: start the backend

	testhelpers.ResetTestDatabase(s.backend.DbMap)

	s.app = NewApp(s.backend, s.config)
	s.server = httptest.NewServer(s.app)
}
示例#3
0
func (s *SQLiteNotificationBackendSuite) SetUpTest(c *C) {
	logrusTestHook.ClearLogs()

	s.backend = backend.GetBackend(BackendName).(*SQLiteNotificationBackend)
	c.Assert(s.backend.Name(), Equals, BackendName)

	err := s.backend.Initialize(":memory:,test_config/standard.conf.json")
	c.Assert(err, IsNil)

	testhelpers.ResetTestDatabase(s.backend.DbMap)

	s.notifier = testhelpers.NewTestNotifier()
	backend.ClearAllNotifiers()
	backend.RegisterNotifier(s.notifier)

	logrusTestHook.ClearLogs()
}