Skip to content

Commit

Permalink
improve documentation and program log info
Browse files Browse the repository at this point in the history
  • Loading branch information
liuqing6767 committed Oct 20, 2021
1 parent 14bcc04 commit 3090ed8
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 22 deletions.
Binary file added .DS_Store
Binary file not shown.
16 changes: 10 additions & 6 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# This is an example .goreleaser.yml file with some sane defaults.
# Make sure to check the documentation at https://goreleaser.com
builds:
-
goos:
- darwin
- linux
- windows
goarch:
- amd64
- arm
- arm64
archives:
-
replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
files:
- LICENSE
- docs/*
Expand Down
12 changes: 7 additions & 5 deletions conf/conf-agent.toml
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
[Logger]
LogDir = "./log/"
LogName = "conf_gent"
LogLevel = "DEBUG"
LogLevel = "INFO"
RotateWhen = "MIDNIGHT"
BackupCount = 2
Format = "[%D %T] [%L] [%S] %M"
StdOut = true
StdOut = false

[Basic]
BFECluster = "ALB-test-02"
BFECluster = "{BFECluster}"
BFEConfDir = "/home/work/bfe/conf"
BFEMonitorPort = 8421
BFEReloadTimeoutMs = 1500

ReloadIntervalMs = 5000

ConfServer = "http://127.0.0.1:8183"
ConfTaskHeaders = {"Authorization" = "Session bS9YlAKPFmtSdIp8_yvJ"}
# Token 获取参考 https://github.com/bfenetworks/dashboard/blob/develop/docs/zh-cn/user-guide/system-view/user-management.md#token%E7%AE%A1%E7%90%86
ConfTaskHeaders = {"Authorization" = "Session {Token}"}
ConfTaskTimeoutMs = 1500

ExtraFileServer = "http://127.0.0.1:8183/inner-api/v1/configs/extra_files/"
ExtraFileTaskHeaders = {"Authorization" = "Session bS9YlAKPFmtSdIp8_yvJ"}
# Token 获取参考 https://github.com/bfenetworks/dashboard/blob/develop/docs/zh-cn/user-guide/system-view/user-management.md#token%E7%AE%A1%E7%90%86
ExtraFileTaskHeaders = {"Authorization" = "Session {Token}"}
ExtraFileTaskTimeoutMs = 1500


Expand Down
14 changes: 11 additions & 3 deletions conf_reload/reloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,19 @@ func (r *Reloader) Start() {
}

func (r *Reloader) reload(ctx context.Context) {
xlog.Default.Info(xlog.InfoLogFormat(ctx, "reload begin"))

// fetch newer data file
fileList, err := r.prober.Probe(ctx)
if err != nil {
xlog.Default.Error(xlog.ErrLogFormat(ctx, "probe", err))
return
}
xlog.Default.Info(xlog.InfoLogFormat(ctx, "probe succ"))

// no newer data file, exit
if len(fileList) == 0 {
xlog.Default.Info(xlog.InfoLogFormat(ctx, "exit", "without_update"))
xlog.Default.Info(xlog.InfoLogFormat(ctx, "reload succ", "without_update"))
return
}

Expand All @@ -100,20 +103,25 @@ func (r *Reloader) reload(ctx context.Context) {
// store all newer data file
err = r.fileStore.StoreFile2TmpDir(ctx, version, files)
if err != nil {
xlog.Default.Error(xlog.ErrLogFormat(ctx, "StoreFile2TmpDir fail", err))
return
}
xlog.Default.Info(xlog.InfoLogFormat(ctx, "StoreFile2TmpDir succ"))

// trigger bfe reload
err = r.trigger.TriggerBFEReload(ctx, version)
if err != nil {
xlog.Default.Error(xlog.ErrLogFormat(ctx, "TriggerBFEReload fail", err))
return
}
xlog.Default.Info(xlog.InfoLogFormat(ctx, "TriggerBFEReload succ"))

// replace old config by newest, if fail, it's ok
err = r.fileStore.UpdateDefaultConfDir(ctx, version)
if err != nil {
xlog.Default.Info(xlog.ErrLogFormat(ctx, "UpdateDefaultConfDir", err))
xlog.Default.Error(xlog.ErrLogFormat(ctx, "UpdateDefaultConfDir fail", err))
}
xlog.Default.Info(xlog.InfoLogFormat(ctx, "UpdateDefaultConfDir succ"))

xlog.Default.Info(xlog.InfoLogFormat(ctx, "exit", "update"))
xlog.Default.Info(xlog.InfoLogFormat(ctx, "reload succ", "update"))
}
19 changes: 13 additions & 6 deletions docs/zh_cn/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
# conf-agent

## 1. conf-agent 说明
## conf-agent 说明
conf-agent 从 api-server 获取最新的配置并触发bfe热加载。

## 2. 获取方式
## 获取方式
获取 `conf-agent` 工具。获取 `conf-agent` 有多种方式:
- 在relase页面下载对应平台的可执行文件
- 通过 `go get` 工具本地编译
- 下载本仓库,执行 `make` (需要go开发环境)

## 3. 配置说明
## 配置说明
在api-server有对应导出接口的前提下,conf-agent通过配置能够支持所有的module的配置拉取和热加载。

配置详见[配置详情](./config.md)
- 访问 API Server 需要 在配置文件中配置 Token,获取方式见[通过Dashboard获取Token](https://github.com/bfenetworks/dashboard/blob/develop/docs/zh-cn/user-guide/system-view/user-management.md#token%E7%AE%A1%E7%90%86)
- BFECluster 配置为在控制台配置的有效 BFE Cluster,配置方式见[通过Dashboard配置BFECluster](https://github.com/bfenetworks/dashboard/blob/develop/docs/zh-cn/user-guide/system-view/bfe-cluster-and-pool.md#bfe%E9%9B%86%E7%BE%A4%E7%9A%84%E9%85%8D%E7%BD%AE)

## 4. 部署和启动
## 部署和启动
和 bfe同机部署

启动命令为:
Expand All @@ -23,5 +25,10 @@ conf-agent 从 api-server 获取最新的配置并触发bfe热加载。
./conf-agent -c ../conf/ -cf conf-agent.toml
```

## 5. 实现原理
详见[实现原理](./implementation.md)
## 实现原理
详见[实现原理](./implementation.md)


## 关于BFE
- 官网:https://www.bfe-networks.net
- 书籍:[《深入理解BFE》](https://github.com/baidu/bfe-book) :介绍网络接入的相关技术原理,说明BFE的设计思想,以及如何基于BFE搭建现代化的网络接入平台。现已开放全文阅读。
4 changes: 2 additions & 2 deletions docs/zh_cn/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
| BFEReloadTimeoutMs | int | BFE reload 超时设置 | N | 1500 | |
| ReloadIntervalMs | int | 拉取时间间隔 | N | 10000 | |
| ConfServer | string | APIServer服务器,用来拉取配置 | Y | - | |
| ConfTaskHeaders | map\<string\>string | 静态文件请求Header | N | - | |
| ConfTaskHeaders | map\<string\>string | 配置请求Header, Api Server 当前会对请求鉴权,需要设置 Authorization 头, [通过Dashboard获取Token](https://github.com/bfenetworks/dashboard/blob/develop/docs/zh-cn/user-guide/system-view/user-management.md#token%E7%AE%A1%E7%90%86) | N | - | |
| ConfTaskTimeoutMs | int | 配置拉取超时 | Y | 2500 | |
| ExtraFileServer | string | 静态文件服务器,用来拉取静态文件 | Y | - | |
| ExtraFileTaskHeaders | map\<string\>string | 静态文件请求Header | N | - | |
| ExtraFileTaskHeaders | map\<string\>string | 静态文件请求Header, Api Server 当前会对请求鉴权,需要设置 Authorization 头, [通过Dashboard获取Token](https://github.com/bfenetworks/dashboard/blob/develop/docs/zh-cn/user-guide/system-view/user-management.md#token%E7%AE%A1%E7%90%86) | N | - | |
| ExtraFileTaskTimeoutMs | int | 静态文件拉取超时 | Y | 2500 | |

## 3 Reloaders配置
Expand Down

0 comments on commit 3090ed8

Please sign in to comment.