bifrost

package
v1.0.0-alpha.7 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2020 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 认证接口错误返回
	ErrorReasonServerBusy    = "服务器繁忙"
	ErrorReasonRelogin       = "请重新登陆"
	ErrorReasonWrongPassword = "用户或密码错误"
)
View Source
const (
	// 日志级别
	CRITICAL = logger.CriticalLevel
	ERROR    = logger.ErrorLevel
	WARN     = logger.WarningLevel
	NOTICE   = logger.NoticeLevel
	INFO     = logger.InfoLevel
	DEBUG    = logger.DebugLevel

	// 版本号
	VERSION = "v1.0.0-alpha.7"

	// Web服务类型
	NGINX WebServerType = "nginx"
	HTTPD WebServerType = "httpd"
)

Variables

View Source
var (
	Signal = flag.String("s", "", "send `signal` to a master process: stop, restart, status")

	// bifrost配置
	BifrostConf *Config

	// 日志文件
	Logf    *os.File
	Stdoutf *os.File
)
View Source
var (
	ExpireTime = 3600 // token有效期
)

Functions

func ListenSignal

func ListenSignal(sigChan chan<- int)

func Log

func Log(level logger.LogLevel, message string, a ...interface{})

Log, 日志记录函数 参数:

level: 日志级别对象
message: 需记录的日志信息字符串

func PathExists

func PathExists(path string) (bool, error)

PathExists, 判断文件路径是否存在函数 参数:

path: 待判断的文件路径字符串

返回值:

true: 存在; false: 不存在
错误

func Restart

func Restart() error

Restart, 守护进程 restart 方法函数 返回值:

错误

func Run

func Run()

Run, bifrost启动函数

func Start

func Start() (err error)

Start, 守护进程 start 方法函数 返回值:

错误

func Status

func Status() (int, error)

Status, 守护进程 status 方法函数 返回值:

错误

func Stop

func Stop() error

Stop, 守护进程 stop 方法函数 返回值:

错误

Types

type AuthConfig

type AuthConfig struct {
	Username string `yaml:"username"`
	Password string `yaml:"password"`
}

AuthConfig, 认证信息结构体,记录用户认证信息(可选)

type AuthDBConfig

type AuthDBConfig struct {
	DBName   string `yaml:"DBName"`
	Host     string `yaml:"host"`
	Port     int    `yaml:"port"`
	Protocol string `yaml:"protocol"`
	User     string `yaml:"user"`
	Password string `yaml:"password"`
}

AuthDBConfig, mysql数据库信息结构体,该库用于存放用户认证信息(可选)

type Config

type Config struct {
	WebServerInfo WebServerInfo `yaml:"WebServerInfo"`
	*AuthDBConfig `yaml:"AuthDBConfig,omitempty"`
	*AuthConfig   `yaml:"AuthConfig,omitempty"`
	LogConfig     `yaml:"LogConfig"`
}

Config, bifrost配置文件结构体,定义bifrost配置信息

type JWTClaims

type JWTClaims struct {
	jwt.StandardClaims
	UserID      int      `json:"user_id"`
	Password    string   `json:"password"`
	Username    string   `json:"username"`
	FullName    string   `json:"full_name"`
	Permissions []string `json:"permissions"`
}

JWTClaims, jwt断言对象,定义认证接口校验的用户信息

type LogConfig

type LogConfig struct {
	LogDir string          `yaml:"logDir"`
	Level  logger.LogLevel `yaml:"level"`
}

LogConfig, bifrost日志信息结构体,定义日志目录、日志级别

type ServerInfo

type ServerInfo struct {
	Name           string        `yaml:"name"`
	ServerType     WebServerType `yaml:"serverType"`
	BaseURI        string        `yaml:"baseURI"`
	BackupCycle    int           `yaml:"backupCycle"`
	BackupSaveTime int           `yaml:"backupSaveTime"`
	BackupDir      string        `yaml:"backupDir,omitempty"`
	ConfPath       string        `yaml:"confPath"`
	VerifyExecPath string        `yaml:"verifyExecPath"`
	// contains filtered or unexported fields
}

ServerInfo, nginx配置文件信息结构体,定义配置文件路径、nginx可执行文件路径和bifrost为其提供接口的路由及侦听端口

func (*ServerInfo) AutoReload

func (si *ServerInfo) AutoReload(signal chan int)

AutoReload, ServerInfo的web服务器配置文件自动热加载方法 参数:

c: 整型管道,用于停止备份

func (ServerInfo) Bak

func (si ServerInfo) Bak(signal chan int)

Bak, ServerInfo的nginx配置文件备份方法 参数:

c: 整型管道,用于停止备份

type WebServerInfo

type WebServerInfo struct {
	ListenPort int          `yaml:"listenPort"`
	Servers    []ServerInfo `yaml:"servers,flow"`
}

WebServerInfo, bifrost配置文件对象中web服务器信息结构体,定义管控的web服务器配置文件相关信息

type WebServerType

type WebServerType string

WebServerType, web服务器类型对象,定义web服务器所属类型

Jump to

Keyboard shortcuts

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