mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-04 12:40:07 +00:00
♻️ register when upgrade
This commit is contained in:
@@ -25,7 +25,7 @@ var (
|
||||
server string
|
||||
clientSecret string
|
||||
debug bool
|
||||
version string = "0.1.4"
|
||||
version string
|
||||
|
||||
rootCmd = &cobra.Command{
|
||||
Use: "nezha-agent",
|
||||
@@ -39,6 +39,15 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
var (
|
||||
endReport time.Time
|
||||
reporting bool
|
||||
client pb.NezhaServiceClient
|
||||
ctx = context.Background()
|
||||
delayWhenError = time.Second * 10
|
||||
updateCh = make(chan struct{}, 0)
|
||||
)
|
||||
|
||||
func doSelfUpdate() {
|
||||
defer func() {
|
||||
time.Sleep(time.Minute * 20)
|
||||
@@ -55,6 +64,7 @@ func doSelfUpdate() {
|
||||
// latest version is the same as current version. It means current binary is up to date.
|
||||
log.Println("Current binary is the latest version", version)
|
||||
} else {
|
||||
client.Register(ctx, monitor.GetHost().PB())
|
||||
log.Println("Successfully updated to version", latest.Version)
|
||||
log.Println("Release note:\n", latest.ReleaseNotes)
|
||||
}
|
||||
@@ -74,13 +84,6 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
var endReport time.Time
|
||||
var reporting bool
|
||||
var client pb.NezhaServiceClient
|
||||
var ctx = context.Background()
|
||||
var delayWhenError = time.Second * 10
|
||||
var updateCh = make(chan struct{}, 0)
|
||||
|
||||
func run(cmd *cobra.Command, args []string) {
|
||||
dao.Conf = &model.Config{
|
||||
Debug: debug,
|
||||
|
||||
Reference in New Issue
Block a user