1.从github拉取哪吒探针最新源码,进入源码根目录。

2.修改cmd/dashboard/main.go:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import (
"...."
"...."
"os"
"fmt"
"...."
"...."
"...."
)
....
....
func init() {

//新建conf文件
file6, err := os.Create("data/config.yaml")
if err != nil {
fmt.Println(err)
}
data := `debug: false
httpport: 80
grpcport: 7777
oauth2:
type: "github" #Oauth2 登录接入类型,gitee/github
admin: "" #管理员列表,半角逗号隔开
clientid: "" # 在 https://github.com/settings/developers 创建,无需审核 Callback 填 http(s)://域名或IP/oauth2/callback
clientsecret: ""
site:
brand: "名字"
cookiename: "nezha-dashboard" #浏览器 Cookie 字段名,可不改
theme: "default"
`
file6.WriteString(data)
file6.Close()
// 初始化 dao 包

singleton.Init()
singleton.InitConfigFromPath("data/config.yaml")
singleton.InitDBFromPath("data/sqlite.db")
singleton.InitLocalizer()
initSystem()
}

3.编辑生成的fly.toml为:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
app = "名字"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[env]

[experimental]
allowed_public_ports = []
auto_rollback = true

[mounts]
destination = "/dashboard/data"
source = "卷名,随便起,下面用的到"

[[services]]
http_checks = []
internal_port = 80
processes = ["app"]
protocol = "tcp"
script_checks = []
[services.concurrency]
hard_limit = 25
soft_limit = 20
type = "connections"

[[services.ports]]
handlers = ["http"]
port = 80

[[services.ports]]
handlers = ["tls", "http"]
port = 443

[[services.tcp_checks]]
grace_period = "1s"
interval = "15s"
restart_limit = 0
timeout = "2s"

[[services]]
http_checks = []
internal_port = 7777
processes = ["app"]
protocol = "tcp"
script_checks = []
[services.concurrency]
hard_limit = 25
soft_limit = 20
type = "connections"

[[services.ports]]
port = 7777

[[services.tcp_checks]]
grace_period = "1s"
interval = "15s"
restart_limit = 0
timeout = "2s"

4.为了数据持久化,创建一个卷存放数据:

1
fly volumes create 卷名 --region hkg --size 1

5.启动:

1
fly deploy --no-cache --remote-only

6.等待创建完毕就大功告成了!