Documentation
¶
Index ¶
- type LightbringerTOML
- type Manager
- func (m *Manager) Done() <-chan struct{}
- func (m *Manager) IsRunning() bool
- func (m *Manager) MonitorAndRestart(stopCh <-chan struct{}, maxRetries int)
- func (m *Manager) Pid() int
- func (m *Manager) Start() error
- func (m *Manager) Stop(timeout time.Duration) error
- func (m *Manager) WaitReady(timeout time.Duration) error
- func (m *Manager) WriteConfig() (string, error)
- type ManagerConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LightbringerTOML ¶
type LightbringerTOML struct {
GossipEntrypoint string
Storage string
RpcAddr string
GrpcAddr string
// Optional sections
InfluxdbHost string
InfluxdbDatabase string
InfluxdbToken string
BlockConfirmRpcHTTP string
BlockConfirmRpcWS string
// Quiet emits [log] quiet = true so Lightbringer logs at Warn level only.
Quiet bool
}
LightbringerTOML represents the Lightbringer.toml structure that Lightbringer expects. This mirrors the Rust ConfigRaw struct in the Lightbringer source.
func (*LightbringerTOML) GenerateTOML ¶
func (c *LightbringerTOML) GenerateTOML() string
GenerateTOML produces a valid Lightbringer.toml string from the config.
func (*LightbringerTOML) Validate ¶
func (c *LightbringerTOML) Validate() error
Validate checks that required fields are present and well-formed.
func (*LightbringerTOML) WriteConfigFile ¶
func (c *LightbringerTOML) WriteConfigFile(dir string) (string, error)
WriteConfigFile writes Lightbringer.toml to the given directory using an atomic write pattern (write to temp file, then rename) to prevent partial writes.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles the lifecycle of a Lightbringer child process: config generation, spawning, log capture, health checking, and shutdown.
func NewManager ¶
func NewManager(cfg ManagerConfig) *Manager
NewManager creates a new Lightbringer process manager.
func (*Manager) Done ¶
func (m *Manager) Done() <-chan struct{}
Done returns a channel that is closed when the Lightbringer process exits. Returns nil if Start has not been called.
func (*Manager) IsRunning ¶
IsRunning returns true if the Lightbringer process is currently running.
func (*Manager) MonitorAndRestart ¶
MonitorAndRestart watches for unexpected Lightbringer exits and restarts with exponential backoff. Stops monitoring when stopCh is closed. maxRetries=0 means unlimited retries. Returns when stopped or max retries exceeded.
func (*Manager) Start ¶
Start spawns the Lightbringer process and begins capturing its output. On Linux, Pdeathsig ensures the kernel sends SIGTERM to Lightbringer if Mithril exits for any reason (including os.Exit, SIGKILL, panic).
func (*Manager) Stop ¶
Stop sends SIGTERM to the Lightbringer process and waits for it to exit. If the process doesn't exit within the timeout, it sends SIGKILL.
func (*Manager) WaitReady ¶
WaitReady polls the gRPC endpoint until it accepts a TCP connection, or the timeout expires.
func (*Manager) WriteConfig ¶
WriteConfig generates Lightbringer.toml in the configured directory. Returns an error if required fields are missing.
type ManagerConfig ¶
type ManagerConfig struct {
BinaryPath string
ConfigDir string
GrpcAddr string
TOML LightbringerTOML
LogWriter io.Writer // where captured stdout/stderr is written
}
ManagerConfig holds the parameters needed to create a Manager.