supervisor

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package supervisor 管理本项目的服务进程、控制通道和监听资源。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Attach added in v0.1.1

func Attach(ctx context.Context, socket string, specs map[string]Spec, output io.Writer) (bool, error)

Attach transfers local terminal ownership after the requested services are ready. Closing the current owner stops the manager; closing a replaced owner has no effect.

func ConfigureHorizon

func ConfigureHorizon()

ConfigureHorizon 通过公开扩展接口限定本代服务的停机范围,队列和监控数据仍由原 Store 管理。

func Frontend

func Frontend(ctx context.Context, spec Spec) error

Frontend 与 Go 服务使用同样的子进程回收逻辑,由外层管理器决定是否重启。

func Parse

func Parse(selection, action string) ([]string, error)

Parse 供 CLI 和本地控制通道共用同一套服务选择规则。

func Ready

func Ready() error

Ready 通过父进程提供的管道报告本服务已经就绪。

func Run

func Run(ctx context.Context, socket string, specs map[string]Spec, names []string, watch bool) error

Run 持有排他锁和本地控制入口,直到收到停止命令或应用退出信号。

func Terminal added in v0.1.1

func Terminal(ctx context.Context, socket string, launcher Spec, specs map[string]Spec, output io.Writer) (result error)

Terminal starts an independent local manager when absent, then owns its control connection.

func Watch added in v0.1.1

func Watch(ctx context.Context, directory, runtime string, reload func(string) error) error

Watch 监听应用及本地模块源码,编译成功后更新运行中的 Go 服务。

func WatchParent

func WatchParent(ctx context.Context, shutdown func(error)) (func(), error)

WatchParent 在管理器异常消失时通知当前 Application 收尾。

Types

type Response

type Response struct {
	PID         int      `json:"pid"`
	TerminalPID int      `json:"terminal_pid,omitempty"`
	Replaced    bool     `json:"replaced,omitempty"`
	Services    []Status `json:"services"`
	Error       string   `json:"error,omitempty"`
}

func Control

func Control(ctx context.Context, socket, selection, action string) (Response, bool, error)

Control 向已经运行的本地管理器提交操作并等待结果。

type Spec

type Spec struct {
	Command             []string
	Dir, Address, Probe string
	Env                 []string
	Timeout             time.Duration
	JoinGroup           bool
}

Spec 声明服务的执行入口;Address 用于继承监听器,Probe 用于前端就绪检查。

type Status

type Status struct {
	Name      string `json:"name"`
	State     string `json:"state"`
	Wanted    bool   `json:"wanted"`
	PID       int    `json:"pid"`
	Restarts  int    `json:"restarts"`
	StartedAt int64  `json:"started_at"`
	LastError string `json:"last_error,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL