Documentation ¶
Index ¶
- Variables
- func CloseCtrl()
- func SetName(name string)
- func Setup(startFunction StartFunc)
- func Shutdown()
- type Keeper
- func (that *Keeper) AddAppToExecutor(app kapp.IApp, executorName ...string)
- func (that *Keeper) CheckKeeperForStart()
- func (that *Keeper) Config() *gcfg.Config
- func (that *Keeper) EnableMultiProc()
- func (that *Keeper) GetExecutorsRunning() *gmap.StrAnyMap
- func (that *Keeper) GetGFConf(confFile string) *gcfg.Config
- func (that *Keeper) InitCli()
- func (that *Keeper) InitKtrl()
- func (that *Keeper) InitLogCfg()
- func (that *Keeper) InitLogSetting(config *gcfg.Config) error
- func (that *Keeper) IsMaster() bool
- func (that *Keeper) IsMutilProcModeAndInMaster() bool
- func (that *Keeper) IsSingleProcMode() bool
- func (that *Keeper) KCtrlCheckExecutor(c *goktrl.Context) bool
- func (that *Keeper) KtrlDebug()
- func (that *Keeper) KtrlLog()
- func (that *Keeper) KtrlReload()
- func (that *Keeper) KtrlStartApps()
- func (that *Keeper) KtrlStartExecutor()
- func (that *Keeper) KtrlStopApps()
- func (that *Keeper) KtrlStopExecutor()
- func (that *Keeper) ListOfAppsToStart() *garray.StrArray
- func (that *Keeper) Mode() ktype.ProcMode
- func (that *Keeper) ParseConfig(conf string)
- func (that *Keeper) ParseDaemon(daemon bool)
- func (that *Keeper) ParseDebug(debug bool)
- func (that *Keeper) ParseEnv(env string)
- func (that *Keeper) ParsePidFilePath(pidFilePath string)
- func (that *Keeper) ProcManager() *process.Manager
- func (that *Keeper) PutMasterPidInFile()
- func (that *Keeper) RunExecutors()
- func (that *Keeper) RunKeeper()
- func (that *Keeper) SetAppsToOperate(appNames []string)
- func (that *Keeper) SetCurrentExecutor(execName string)
- func (that *Keeper) SetRootCommand(c *cobra.Command)
- func (that *Keeper) SetupStartFunc(startFunction StartFunc)
- func (that *Keeper) Shutdown(timeout ...time.Duration)
- func (that *Keeper) StartApps(execName string, appNames ...string) (r string)
- func (that *Keeper) StartExecutor(execName string, appNames ...string) (r string)
- func (that *Keeper) StopApps(appName string) (r string)
- func (that *Keeper) StopExecutor(execName string) (r string)
- func (that *Keeper) StopKeeper(sig string)
- func (that *Keeper) Version()
- type StartFunc
- type StopFunc
Constants ¶
This section is empty.
Variables ¶
var ( BuildVersion = "No Version Info" BuildGoVersion = "No Version Info" BuildGitCommitId = "No Commit Info" BuildTime = "No Time Info" Authors = "No Authors Info" Logo = `` /* 219-byte string literal not displayed */ )
Version相关信息
默认Keeper
Functions ¶
Types ¶
type Keeper ¶
type Keeper struct { *cobra.Command // 命令行参数解析 *process.Manager // 进程管理者:保存所有Executor, Executor实现process.IProc接口 ExecutorsRunning *gmap.StrAnyMap // 主进程中,记录正在运行的Executors列表 CurrentExecutor string // 子进程中,记录正在执行的Executor KeeperName string // 微服务管理者keeper的名称 KeeperIsMaster bool // 是否为主进程 KConfigPath string // 配置文件路径 KConfig *gcfg.Config // keeper的配置信息 AppsToOperate *garray.StrArray // 记录当前需要启动或停止的App的名称列表 PidFilePath string // 主进程的pid文件保存路径 ProcMode ktype.ProcMode // 进程模式,MultiProcs:多进程模式;SingleProc:单进程模式, 默认单进程 StartFunction StartFunc // keeper启动方法 StartTime *gtime.Time // keeper启动时间 Exiting bool // keeper正在关闭 BeforeStopFunc StopFunc // 服务关闭之前执行该方法 CanCtrl bool // 是否开启交互式shell功能,默认true KCtrl *goktrl.Ktrl // 交互式shell KCtrlSocket string // 默认Unix套接字名称 IsCtrlInitiated bool // KCtrl是否已经初始化 }
Keeper 微服务管理者,主要是进程管理; 主要功能有: 进程开启、停止、重启——process.Manager; 交互式shell命令——KCtrl; 平滑重启——Kgrace; 命令行参数解析——cobra.Command;
func (*Keeper) AddAppToExecutor ¶
AddAppToExecutor 向Executor中添加App;executorName执行器名称作为可选参数; 如果传入了executorName,则使用相应的Executor; 如果未传入executorName,则使用与Keeper同名的默认Executor; 如果要使用的Executor不存在,则先创建; 本方法主要是在用户编写的startFunction中调用,以便将用户编写的App加入到对应的Executor中;
func (*Keeper) CheckKeeperForStart ¶
func (that *Keeper) CheckKeeperForStart()
CheckKeeperStart 检查keeper是否已经启动过; 如果主进程的pid文件名存在,则说明keeper已经启动过。
func (*Keeper) EnableMultiProc ¶
func (that *Keeper) EnableMultiProc()
是否开启多进程模式,也是由用户在startFunction中调用,开启多进程模式
func (*Keeper) GetExecutorsRunning ¶
func (*Keeper) InitLogSetting ¶
日志初始化 通过参数设置日志级别 日志级别通过环境默认分三个类型,开发环境,测试环境,生产环境 开发环境: 日志级别为 DEVELOP,标准输出打开 测试环境:日志级别为 INFO,除了debug日志,都会被打印,标准输出关闭 生产环境: 日志级别为 PRODUCT,会打印 WARN,ERRO,CRIT三个级别的日志,标准输出为关闭 Debug开关会无视以上设置,强制把日志级别设置为ALL,并且打开标准输出。
func (*Keeper) IsMutilProcModeAndInMaster ¶
IsMutilProcModeAndInMaster 判断是否是多进程模式,并且当前正在主进程中执行
func (*Keeper) IsSingleProcMode ¶
func (*Keeper) KtrlReload ¶
func (that *Keeper) KtrlReload()
func (*Keeper) KtrlStartExecutor ¶
func (that *Keeper) KtrlStartExecutor()
KtrlStartExecutor 启动一个Executor,可以指定启动一部分app
func (*Keeper) KtrlStopApps ¶
func (that *Keeper) KtrlStopApps()
func (*Keeper) KtrlStopExecutor ¶
func (that *Keeper) KtrlStopExecutor()
KtrlStopExecutor 停止一个Executor
func (*Keeper) ListOfAppsToStart ¶
func (*Keeper) ParseDaemon ¶
func (*Keeper) ParseDebug ¶
func (*Keeper) ParsePidFilePath ¶
func (*Keeper) ProcManager ¶
func (*Keeper) RunExecutors ¶
func (that *Keeper) RunExecutors()
RunExecutors 根据命令行参数执行ExecutorList中的Executor
func (*Keeper) SetAppsToOperate ¶
func (*Keeper) SetCurrentExecutor ¶
func (*Keeper) SetRootCommand ¶
func (*Keeper) SetupStartFunc ¶
SetupStartFunc 启动服务,并执行传入的启动方法; 本方法是用户执行的起始入口; 参数startFunction: 启动时需要执行的方法;
func (*Keeper) StartExecutor ¶
StartExecutor 交互式shell开启Executor,只在主进程中执行
func (*Keeper) StopExecutor ¶
func (*Keeper) StopKeeper ¶
StopKeeper keeper的stop、reload、quit命令的执行入口