app_manager

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APPConfigsRoot = "conf/app"
	APPScriptsRoot = "conf/manager" // 当前独立与zeus
	ConfigSuffix   = ".pig"
	APPStart       = "start"
	APPStop        = "stop"
	APPExit        = "exit"
	APPRestart     = "restart"
	APPKilled      = "killed"
	APPRunning     = "running"
)
View Source
const (
	APPStatusError
	APPStatusStart
	APPStatusStop
	APPStatusExit
	APPStatusRestart
	APPStatusKilled
	APPStatusRunning
)
View Source
const (
	TypeService    = "Service"    // 服务
	TypeWebFront   = "FrontEnd"   // 前端
	TypeMiddleWare = "MiddleWare" // 中间件
	TypeDataStore  = "DataStore"  // 数据层
)

app的默认类型

View Source
const (
	Published = "published" // 已发布
	Testing   = "testing"   // 测试中
	Pending   = "pending"   // 待发布
)

app的发布状态

View Source
const (
	ConfNginx    = "nginx"
	ConfGunicorn = "gunicorn"
)

配置文件类型

View Source
const APPManagerPrefix = "[APP Manager]"
View Source
const (
	APPNotExist = "app not exist"
)
View Source
const APPStatusOK = 0
View Source
const AppUnknown = 555
View Source
const CollectName = "microservice"
View Source
const PersistFile = "apolloServices.bson"

Variables

View Source
var APPManager = appManager{
	APPManagerMap: sync.Map{},
	APPUsingPorts: map[int]struct{}{},
}
View Source
var StatusMap = map[int]string{
	APPStatusOK:    "running",
	APPStatusError: "stopped",
	APPStatusExit:  "stopped",
	AppUnknown:     "unknown",
}

StatusMap 返回状态使用的状态表

Functions

func Check

func Check(app string) bool

Check 检查是否存在此App

func FirstLoad

func FirstLoad()

FirstLoad 在异常情况下重启,先从mongo拿数据保存后续再刷新

func GetAllAppName added in v1.1.3

func GetAllAppName() ([]string, error)

func InitAPPManager

func InitAPPManager()

InitAPPManager 初始化app manager

func LoadManagerCf

func LoadManagerCf() error

LoadManagerCf 加载所有配置文件到全局的字典中

func LoadToMap

func LoadToMap(appName string) error

LoadToMap 直接更新到全局的管理字典中

func NewApp

func NewApp(appName string) error

NewApp 新建一个APP配置文件

func NewAppScript

func NewAppScript(appName string) error

NewAppScript 新增app 命令目录 默认只创建start stop check

func Persist

func Persist()

Persist 持久化为bson数据 todo 序列化bson文件

func ReStart

func ReStart(app string) (bool, error)

ReStart app快速重启

func ReloadManagerMap added in v1.0.7

func ReloadManagerMap() error

ReloadManagerMap 运行时刷新数据 只做增量更新 数据的更新由AppSync任务完成

func SavePort

func SavePort(app string, port []int)

func SaveRuntimeData

func SaveRuntimeData(app App)

func SaveToDB

func SaveToDB()

SaveToDB 批量插入

func SaveToFile

func SaveToFile(cf *App, appName string) error

SaveToFile 保存配置到文件中

func Start

func Start(app string) (bool, error)

Start app快速启动

func StartAll

func StartAll() ([]string, error)

StartAll 启动所有服务 服务的启动可以异步 并且不受其他服务报错的影响

func Status

func Status(app string) (string, error)

Status 获取指定app状态

func StatusAll

func StatusAll() ([]string, error)

func Stop

func Stop(app string) (bool, error)

Stop app快速停止

func StopAll

func StopAll() ([]string, error)

StopAll 停止所有服务

func SyncAll added in v1.1.3

func SyncAll() error

func SyncApp added in v1.1.3

func SyncApp(app string) (bool, error)

Types

type App

type App struct {
	Meta octopus_meta.App `json:"meta" bson:"meta"`
}

App model for app

func GetAllApp

func GetAllApp() ([]App, error)

GetAllApp 获取所有App

func GetApp

func GetApp(app string) (App, error)

GetApp 获取指定App

func (*App) BackUp

func (app *App) BackUp() (bool, error)

BackUp 备份服务 当前的备份比较简单 打包整个服务到tar中,去除所有的日志文件和缓存文件

func (*App) Check

func (app *App) Check() (bool, error)

Check 状态检查

func (*App) CheckAppReleaseStatus

func (app *App) CheckAppReleaseStatus() bool

CheckAppReleaseStatus 检查app发布状态 未发布时不进行操作

func (*App) ClearPorts

func (app *App) ClearPorts()

ClearPorts 删除运行时环境

func (*App) ClonePorts

func (app *App) ClonePorts()

ClonePorts 同步缓存中的随机端口组到mongo

func (*App) DepCheck added in v1.1.3

func (app *App) DepCheck() bool

DepCheck 运行时依赖检查 依赖异常时 无法成功启动 停止不受影响 不存在依赖时跳过

func (*App) Dump

func (app *App) Dump() (bool, error)

Dump 安全的保存运行态数据到Map中

func (*App) ForceKill

func (app *App) ForceKill() (bool, error)

ForceKill 查找进程树 全部强制kill

func (*App) Info

func (app *App) Info() interface{}

Info 获取app的基础信息

func (*App) PostTodo

func (app *App) PostTodo() *App

PostTodo 启动前的操作,生成环境变量或动态配置到app中

func (*App) ReStart

func (app *App) ReStart() (bool, error)

func (*App) Reload

func (app *App) Reload() (bool, error)

Reload 重载配置文件

func (*App) Start

func (app *App) Start() (bool, error)

Start 启动服务 每次启动前应该强制校验 先停止服务 rundata中的ports是随机分配的,只能在START中生效

func (*App) Stop

func (app *App) Stop() (bool, error)

func (*App) Sync

func (app *App) Sync() (bool, error)

Sync 从本地文件同步模型数据 能够同步的数据仅包括非运行时数据

func (*App) SyncDB

func (app *App) SyncDB() (bool, error)

SyncDB 安全的保存运行态数据到DB中

func (*App) ToJSON

func (app *App) ToJSON() string

ToJSON 导出为json字符串

func (*App) Validate

func (app *App) Validate() bool

Validate 适用于model的检查器

type DaoAPP

type DaoAPP struct {
	mgm.DefaultModel `bson:",inline"`
	App              `json:"app" bson:"app"`
}

DaoAPP 数据库操作类

func (*DaoAPP) CollectionName

func (app *DaoAPP) CollectionName() string

CollectionName 定义存储名称 不能与app冲突

Jump to

Keyboard shortcuts

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