mirror of
https://github.com/nezhahq/nezha.git
synced 2025-01-22 20:58:14 -05:00
♻️ register when upgrade
This commit is contained in:
parent
a0a3ee317b
commit
7ce1f535f5
@ -25,7 +25,7 @@ var (
|
|||||||
server string
|
server string
|
||||||
clientSecret string
|
clientSecret string
|
||||||
debug bool
|
debug bool
|
||||||
version string = "0.1.4"
|
version string
|
||||||
|
|
||||||
rootCmd = &cobra.Command{
|
rootCmd = &cobra.Command{
|
||||||
Use: "nezha-agent",
|
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() {
|
func doSelfUpdate() {
|
||||||
defer func() {
|
defer func() {
|
||||||
time.Sleep(time.Minute * 20)
|
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.
|
// 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)
|
log.Println("Current binary is the latest version", version)
|
||||||
} else {
|
} else {
|
||||||
|
client.Register(ctx, monitor.GetHost().PB())
|
||||||
log.Println("Successfully updated to version", latest.Version)
|
log.Println("Successfully updated to version", latest.Version)
|
||||||
log.Println("Release note:\n", latest.ReleaseNotes)
|
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) {
|
func run(cmd *cobra.Command, args []string) {
|
||||||
dao.Conf = &model.Config{
|
dao.Conf = &model.Config{
|
||||||
Debug: debug,
|
Debug: debug,
|
||||||
|
@ -190,7 +190,6 @@ install_agent() {
|
|||||||
modify_agent_config() {
|
modify_agent_config() {
|
||||||
echo -e "> 修改Agent配置"
|
echo -e "> 修改Agent配置"
|
||||||
|
|
||||||
cd $NZ_AGENT_PATH
|
|
||||||
curl -L https://raw.githubusercontent.com/naiba/nezha/master/script/nezha-agent.service -o $NZ_AGENT_SERVICE >/dev/null 2>&1
|
curl -L https://raw.githubusercontent.com/naiba/nezha/master/script/nezha-agent.service -o $NZ_AGENT_SERVICE >/dev/null 2>&1
|
||||||
if [[ $? != 0 ]]; then
|
if [[ $? != 0 ]]; then
|
||||||
echo -e "${red}文件下载失败,请检查本机能否连接 raw.githubusercontent.com${plain}"
|
echo -e "${red}文件下载失败,请检查本机能否连接 raw.githubusercontent.com${plain}"
|
||||||
|
Loading…
Reference in New Issue
Block a user