// Package launcher manages the application lifecycle for Go services. // // It orchestrates a sequence of phases — init, assemble, start, wait, shutdown — // across a set of registered [Component] implementations. Any infrastructure piece // (database pool, HTTP server, background worker) that implements the three-method // Component interface can be managed by the launcher. // // # Lifecycle // // OnInit (all components, in order) ← open connections, allocate resources // BeforeStart hooks (in order) ← wire dependencies after all inits done // OnStart (all components, in order) ← start goroutines, begin serving // --- application is running --- // OnStop (all components, reverse) ← graceful shutdown, release resources // // # Basic wiring // // logger := logz.New(logz.Options{}) // lc := launcher.New(logger) // // lc.Append(db, cache, server) // lc.BeforeStart(func() error { // return server.RegisterRoutes(db, cache) // }) // // if err := lc.Run(); err != nil { // logger.Error("launcher failed", err) // os.Exit(1) // } // // Run blocks until SIGINT/SIGTERM is received or [Launcher.Shutdown] is called, // then stops all components in reverse order before returning. package launcher