Skip to content

Commit

Permalink
main: move metrics / debug to another endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
criyle committed Feb 22, 2022
1 parent d00db1c commit a461f88
Show file tree
Hide file tree
Showing 6 changed files with 185 additions and 104 deletions.
30 changes: 17 additions & 13 deletions README.cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
### 系统架构

```text
+------------------------------------------------------------------------+
| 传输层 (HTTP / WebSocket / FFI / ...) |
+------------------------------------------------------------------------+
| 工作协程 (环境池环境生产者 ) |
+-----------------------------------------------------------+------------+
| 运行环境 | 文件存储 |
+--------------------+----------------+---------------------+------+-----+
| Linux (go-sandbox) | Windows (winc) | macOS (app sandbox) | 内存 | 磁盘 |
+--------------------+----------------+---------------------+------+-----+
+----------------------------------------------------------------------------+
| 传输层 (HTTP / WebSocket / FFI / ...) |
+----------------------------------------------------------------------------+
| 工作协程 (运行环境池运行环境生产者 ) |
+-----------------------------------------------------------+----------------+
| 运行环境 | 文件存储 |
+--------------------+----------------+---------------------+----------+-----+
| Linux (go-sandbox) | Windows (winc) | macOS (app sandbox) | 共享内存 | 磁盘 |
+--------------------+----------------+---------------------+----------+-----+
```

### REST API 接口
Expand All @@ -37,11 +37,14 @@
- /file/:fileId GET 下载文件 ID 指定的文件
- /file/:fileId DELETE 删除文件 ID 指定的文件
- /ws /run 接口的 WebSocket 版
- /metrics 提供 prometheus 版监控 (使用 `ES_ENABLE_METRICS=1` 环境变量开启)
- /debug 提供 go 语言调试接口 (使用 `ES_ENABLE_DEBUG=1` 环境变量开启)
- /version 得到本程序编译版本和 go 语言运行时版本
- /config 得到本程序部分运行参数

监控端口(默认监听 `:5052`

- /metrics 提供 prometheus 版监控 (使用 `ES_ENABLE_METRICS=1` 环境变量开启)
- /debug 提供 go 语言调试接口 (使用 `ES_ENABLE_DEBUG=1` 环境变量开启)

### 命令行参数

服务相关:
Expand All @@ -52,7 +55,8 @@
- 默认日志等级是 debug ,使用 `-silent` 关闭 或 使用 `-release` 开启 release 级别日志
- 默认没有开启鉴权,使用 `-auth-token` 指定令牌鉴权
- 默认没有开启 go 语音调试接口,使用 `-enable-debug` 开启,同时将日志层级设为 Debug
- 默认没有开启监控接口,使用 `-enable-metrics` 开启
- 默认没有开启 prometheus 监控接口,使用 `-enable-metrics` 开启
- 在启用 go 语言调试接口或者 prometheus 监控接口的情况下,默认监控接口为 `:5052`,使用 `-monitor-addr` 指定

沙箱相关:

Expand All @@ -75,7 +79,7 @@
- 使用 `-tmp-fs-param` 指定容器内 `tmpfs` 的挂载参数(仅 Linux)
- 使用 `-file-timeout` 指定文件存储文件最大时间。超出时间的文件将会删除。(举例 `30m`
- 使用 `-mount-conf` 指定沙箱文件系统挂载细节,详细请参见 `mount.yaml` (仅 Linux)
- 使用 `-container-init-path` 指定 `cinit` 路径 (请不要使用,仅 debug) (Linux only)
- 使用 `-container-init-path` 指定 `cinit` 路径 (请不要使用,仅 debug) (仅 Linux)

### 环境变量

Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ A REST service to run program in restricted environment and it is basically a wr
- /file/:fileId GET downloads file from executor service (in memory), returns file content
- /file/:fileId DELETE delete file specified by fileId
- /ws WebSocket for /run
- /version gets build git version (e.g. `v1.4.0`) together with runtime information (go version, os, platform)
- /config gets some configuration (e.g. `fileStorePath`) together with some supported features

Monitor HTTP endpoint (default `:5052`, specified by `-monitor-addr`)

- /metrics prometheus metrics (specifies `ES_ENABLE_METRICS=1` environment variable to enable metrics)
- /debug (specifies `ES_ENABLE_DEBUG=1` environment variable to enable go runtime debug endpoint)
- /version gets build git version (e.g. `v0.9.4`) together with runtime information (go version, os, platform)
- /config gets some configuration (e.g. `fileStorePath`) together with some supported features

### Command Line Arguments

Expand All @@ -53,6 +56,7 @@ Server:
- `-auth-token` to add token-based authentication to REST / gRPC
- By default, the GO debug endpoints are disabled, to enable, specifies `-enable-debug`, and it also enables debug log
- By default, the prometheus metrics endpoints are disabled, to enable, specifies `-enable-metrics`
- Monitoring HTTP endpoint is enabled if metrics / debug is enabled, the default addr is `:5052` and can be specified by `-monitor-addr`

Sandbox:

Expand Down
1 change: 1 addition & 0 deletions cmd/executorserver/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type Config struct {
HTTPAddr string `flagUsage:"specifies the http binding address" default:":5050"`
EnableGRPC bool `flagUsage:"enable gRPC endpoint"`
GRPCAddr string `flagUsage:"specifies the grpc binding address" default:":5051"`
MonitorAddr string `flagUsage:"specifies the metrics binding address" default:":5052"`
AuthToken string `flagUsage:"bearer token auth for REST / gRPC"`
EnableDebug bool `flagUsage:"enable debug endpoint"`
EnableMetrics bool `flagUsage:"enable promethus metrics endpoint"`
Expand Down
Loading

0 comments on commit a461f88

Please sign in to comment.