Files
mining-client/cmd/main.go
2025-12-01 15:45:05 +08:00

39 lines
1.0 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package main
import (
client "client/internal"
"client/internal/updater"
"log"
"os"
"os/signal"
"syscall"
)
const VERSION string = "version advanced"
const PROXY_URL string = "47.108.221.51:23456" // 服务地址
const REMOTE_UPDATE_URL = "http://127.0.0.1:23333/update" // 远程更新服务器地址
func main() {
// 启动前检查更新
log.Println("检查更新...")
needRestart, err := updater.CheckAndUpdate(REMOTE_UPDATE_URL, VERSION)
if err != nil {
log.Printf("更新检查失败,继续运行当前版本:%v", err)
} else if needRestart {
log.Println("更新完成!请重启程序以使用新版本。")
os.Exit(0)
}
// 在单独的 goroutine 中启动客户端逻辑
go client.Star(PROXY_URL)
// 监听系统信号,实现优雅退出
sigCh := make(chan os.Signal, 1)
signal.Notify(sigCh, os.Interrupt, syscall.SIGTERM)
sig := <-sigCh
log.Printf("收到退出信号: %v客户端准备退出...", sig)
// 停止客户端(包括持续挖矿)
client.StopClient()
}