process

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AOGProcessManager

type AOGProcessManager struct {
	// contains filtered or unexported fields
}

AOGProcessManager manages the AOG server process from external commands

func GetAOGManager

func GetAOGManager() (*AOGProcessManager, error)

GetAOGManager 返回进程管理器以保持向后兼容 Deprecated: Use GetAOGProcessManager for external process management

func GetAOGProcessManager

func GetAOGProcessManager() (*AOGProcessManager, error)

GetAOGProcessManager returns the global AOG process manager for external use

func (*AOGProcessManager) GetProcessPID

func (m *AOGProcessManager) GetProcessPID() int

GetProcessPID returns the process PID, or -1 if not running

func (*AOGProcessManager) IsProcessHealthy

func (m *AOGProcessManager) IsProcessHealthy() bool

IsProcessHealthy checks if the process is running and healthy

func (*AOGProcessManager) IsProcessRunning

func (m *AOGProcessManager) IsProcessRunning() bool

IsProcessRunning checks if the AOG process is running

func (*AOGProcessManager) StartProcess

func (m *AOGProcessManager) StartProcess(daemon bool) error

StartProcess starts the AOG server process

func (*AOGProcessManager) StartProcessDaemon

func (m *AOGProcessManager) StartProcessDaemon() error

StartProcessDaemon starts the AOG server process in daemon mode

func (*AOGProcessManager) StopProcess

func (m *AOGProcessManager) StopProcess() error

StopProcess stops the AOG server process gracefully

func (*AOGProcessManager) StopProcessWithFallback

func (m *AOGProcessManager) StopProcessWithFallback(pidFilePath string) error

StopProcessWithFallback stops the process with legacy PID file fallback

func (*AOGProcessManager) WaitForReady

func (m *AOGProcessManager) WaitForReady(timeout time.Duration) error

WaitForReady waits for the process to become ready with timeout

type AOGServiceManager

type AOGServiceManager struct {
	// contains filtered or unexported fields
}

AOGServiceManager manages AOG internal services (engines, HTTP server)

func GetAOGServiceManager

func GetAOGServiceManager() *AOGServiceManager

GetAOGServiceManager returns the global AOG service manager for internal use

func NewAOGServiceManager

func NewAOGServiceManager() *AOGServiceManager

NewAOGServiceManager creates a new AOG service manager for internal use

func (*AOGServiceManager) GetStatus

func (m *AOGServiceManager) GetStatus() ProcessStatus

GetStatus returns the service status

func (*AOGServiceManager) SetEngineManager

func (m *AOGServiceManager) SetEngineManager(engineManager EngineManagerInterface)

SetEngineManager sets the engine manager for the service manager

func (*AOGServiceManager) SetHTTPServer

func (m *AOGServiceManager) SetHTTPServer(server interface{})

SetHTTPServer sets the HTTP server reference for graceful shutdown

func (*AOGServiceManager) StartServices

func (m *AOGServiceManager) StartServices(ctx context.Context, startEngines bool, engineMode string) error

StartServices starts internal services (engines, etc.) - NO process creation

func (*AOGServiceManager) StopServices

func (m *AOGServiceManager) StopServices(ctx context.Context) error

StopServices gracefully stops internal services - NO process termination

func (*AOGServiceManager) WaitForShutdown

func (m *AOGServiceManager) WaitForShutdown() <-chan struct{}

WaitForShutdown waits for shutdown signal

type BaseProcessManager

type BaseProcessManager struct {
	// contains filtered or unexported fields
}

BaseProcessManager provides common process management functionality

func (*BaseProcessManager) Info

func (m *BaseProcessManager) Info() ProcessInfo

Info returns process information

func (*BaseProcessManager) IsRunning

func (m *BaseProcessManager) IsRunning() bool

IsRunning checks if the process is currently running

func (*BaseProcessManager) Kill

func (m *BaseProcessManager) Kill() error

Kill forcefully terminates the process

func (*BaseProcessManager) PID

func (m *BaseProcessManager) PID() int

PID returns the process ID (0 if not running)

func (*BaseProcessManager) Start

func (m *BaseProcessManager) Start(ctx context.Context, config *StartConfig) error

Start starts the process with given configuration

func (*BaseProcessManager) Status

func (m *BaseProcessManager) Status() ProcessStatus

Status returns the current process status

func (*BaseProcessManager) Stop

func (m *BaseProcessManager) Stop(ctx context.Context) error

Stop gracefully stops the process

type EngineManagerInterface

type EngineManagerInterface interface {
	StartAllEngines(mode string) error
	StopAllEngines() error
	StartKeepAlive()
	StopKeepAlive()
}

EngineManagerInterface defines the interface for engine management

type EngineProcessManager

type EngineProcessManager struct {
	ProcessManager
	// contains filtered or unexported fields
}

EngineProcessManager manages engine processes with specialized configuration building

func NewEngineProcessManager

func NewEngineProcessManager(engineName string, config *sdktypes.EngineRecommendConfig) *EngineProcessManager

NewEngineProcessManager creates a new engine process manager

func (*EngineProcessManager) StartEngine

func (m *EngineProcessManager) StartEngine(mode string, healthCheck func() error) error

StartEngine starts the engine with specified mode

func (*EngineProcessManager) StopEngine

func (m *EngineProcessManager) StopEngine() error

StopEngine stops the engine gracefully

type PlatformProcess

type PlatformProcess interface {
	// StartProcess starts a process with given command
	StartProcess(cmd *exec.Cmd, mode StartMode) (*ProcessHandle, error)

	// GracefulShutdown gracefully shuts down a process
	GracefulShutdown(ctx context.Context, handle *ProcessHandle) error

	// KillProcess forcefully kills a process
	KillProcess(handle *ProcessHandle) error

	// IsProcessRunning checks if a process is running
	IsProcessRunning(handle *ProcessHandle) bool
}

PlatformProcess defines platform-specific process operations

type ProcessHandle

type ProcessHandle struct {
	Process *exec.Cmd
	PID     int
}

ProcessHandle represents a handle to a running process

type ProcessInfo

type ProcessInfo struct {
	PID    int           `json:"pid"`
	Status ProcessStatus `json:"status"`
	Name   string        `json:"name"`
}

ProcessInfo contains information about a process

type ProcessInfoProvider

type ProcessInfoProvider interface {
	Info() ProcessInfo
}

ProcessInfoProvider provides detailed process information (optional extension)

type ProcessManager

type ProcessManager interface {
	// Core lifecycle operations
	Start(ctx context.Context, config *StartConfig) error
	Stop(ctx context.Context) error
	Kill() error

	// Status queries
	IsRunning() bool
	Status() ProcessStatus
	PID() int
}

ProcessManager defines the core interface for process management

func NewProcessManager

func NewProcessManager(name string) ProcessManager

NewProcessManager creates a new process manager instance

type ProcessStatus

type ProcessStatus int

ProcessStatus represents the status of a process

const (
	ProcessStatusStopped ProcessStatus = iota
	ProcessStatusStarting
	ProcessStatusRunning
	ProcessStatusStopping
	ProcessStatusError
)

func (ProcessStatus) String

func (s ProcessStatus) String() string

type StartConfig

type StartConfig struct {
	Name        string        // 进程名称
	ExecPath    string        // 可执行文件路径
	Args        []string      // 命令行参数
	Env         []string      // 环境变量
	WorkDir     string        // 工作目录
	Mode        StartMode     // 启动模式
	Timeout     time.Duration // 启动超时
	HealthCheck func() error  // 健康检查函数
}

StartConfig contains essential configuration for starting a process

type StartMode

type StartMode string

StartMode defines how the process should be started

const (
	StartModeForeground StartMode = "foreground" // 前台模式,显示输出
	StartModeBackground StartMode = "background" // 后台模式,静默运行
)

type UnixProcess

type UnixProcess struct{}

UnixProcess implements PlatformProcess for Unix-like systems

func (*UnixProcess) GracefulShutdown

func (p *UnixProcess) GracefulShutdown(ctx context.Context, handle *ProcessHandle) error

GracefulShutdown gracefully shuts down a process

func (*UnixProcess) IsProcessRunning

func (p *UnixProcess) IsProcessRunning(handle *ProcessHandle) bool

IsProcessRunning checks if a process is running

func (*UnixProcess) KillProcess

func (p *UnixProcess) KillProcess(handle *ProcessHandle) error

KillProcess forcefully kills a process

func (*UnixProcess) StartProcess

func (p *UnixProcess) StartProcess(cmd *exec.Cmd, mode StartMode) (*ProcessHandle, error)

StartProcess starts a process with given command

Jump to

Keyboard shortcuts

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