不二云端 - 哪吒探针 https://2sv.cn/tag/%E5%93%AA%E5%90%92%E6%8E%A2%E9%92%88/ 如何利用fly.io搭建哪吒探针 https://2sv.cn/archives/202/ 2025-06-30T22:35:49+08:00 AI摘要:通过Fly.io搭建哪吒探针的步骤包括:从GitHub拉取源码并进入根目录,修改`cmd/dashboard/main.go`文件以初始化配置文件,编辑生成的`fly.toml`以设置服务端口和挂载数据卷。之后创建卷进行数据持久化,并通过`fly deploy`命令部署。完成后,便可以通过Fly.io提供的URL访问部署的哪吒探针应用。Powered by AISummary.1.从github拉取哪吒探针最新源码,进入源码根目录。2.修改cmd/dashboard/main.go:import ("....""....""os""fmt""....""....""....")........func init() {//新建conf文件file6, err := os.Create("data/config.yaml")if err != nil {fmt.Println(err)}data := `debug: falsehttpport: 80grpcport: 7777oauth2:type: "github" #Oauth2 登录接入类型,gitee/githubadmin: "" #管理员列表,半角逗号隔开clientid: "" # 在 https://github.com/settings/developers 创建,无需审核 Callback 填 http(s)://域名或IP/oauth2/callbackclientsecret: ""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()}flyctl deploy #填写相关配置信息3.编辑生成的fly.toml为:app = "名字"kill_signal = "SIGINT"kill_timeout = 5processes = [][env][experimental]allowed_public_ports = []auto_rollback = true[mounts]destination = "/dashboard/data"source = "卷名,随便起,下面用的到"[[services]]http_checks = []internal_port = 80processes = ["app"]protocol = "tcp"script_checks = [][services.concurrency]hard_limit = 25soft_limit = 20type = "connections"[[services.ports]]handlers = ["http"]port = 80[[services.ports]]handlers = ["tls", "http"]port = 443[[services.tcp_checks]]grace_period = "1s"interval = "15s"restart_limit = 0timeout = "2s"[[services]]http_checks = []internal_port = 7777processes = ["app"]protocol = "tcp"script_checks = [][services.concurrency]hard_limit = 25soft_limit = 20type = "connections"[[services.ports]]port = 7777[[services.tcp_checks]]grace_period = "1s"interval = "15s"restart_limit = 0timeout = "2s"4.为了数据持久化,创建一个卷存放数据:fly volumes create 卷名 --region hkg --size 15.启动:fly deploy --no-cache --remote-only6.等待创建完毕就大功告成了!demo:https://mynezhatz.fly.dev/