func main() { tutorial := &TutorialService{} config, _ := skynet.GetServiceConfig() config.Name = "TutorialService" config.Version = "1" config.Region = "Development" service := service.CreateService(tutorial, config) defer func() { service.Shutdown() }() waiter := service.Start(true) waiter.Wait() }
func main() { testService := NewTestService() config, _ := skynet.GetServiceConfig() if config.Name == "" { config.Name = "TestService" } if config.Version == "" { config.Version = "1" } if config.Region == "unknown" { config.Region = "Clearwater" } var err error mlogger, err := skynet.NewMongoSemanticLogger("localhost", "skynet", "log", config.UUID) clogger := skynet.NewConsoleSemanticLogger("TestService", os.Stdout) testService.Log = skynet.NewMultiSemanticLogger(mlogger, clogger) config.Log = testService.Log if err != nil { config.Log.Trace("Could not connect to mongo db for logging") } service := service.CreateService(testService, config) // handle panic so that we remove ourselves from the pool in case // of catastrophic failure defer func() { service.Shutdown() if err := recover(); err != nil { log.Println("Unrecovered error occured: ", err) } }() // If we pass false here service will not be Registered we could // do other work/tasks by implementing the Started method and // calling Register() when we're ready waiter := service.Start(true) // waiting on the sync.WaitGroup returned by service.Start() will // wait for the service to finish running. waiter.Wait() }