diff --git a/agent/app/api/v2/setting.go b/agent/app/api/v2/setting.go
index 7af05e35f..e241f0db8 100644
--- a/agent/app/api/v2/setting.go
+++ b/agent/app/api/v2/setting.go
@@ -63,3 +63,11 @@ func (b *BaseApi) UpdateSetting(c *gin.Context) {
func (b *BaseApi) LoadBaseDir(c *gin.Context) {
helper.SuccessWithData(c, global.CONF.System.DataDir)
}
+
+func (b *BaseApi) ReloadConn(c *gin.Context) {
+ if err := settingService.ReloadConn(); err != nil {
+ helper.InternalServer(c, err)
+ return
+ }
+ helper.SuccessWithOutData(c)
+}
diff --git a/agent/app/service/setting.go b/agent/app/service/setting.go
index be456075a..c72437e52 100644
--- a/agent/app/service/setting.go
+++ b/agent/app/service/setting.go
@@ -5,7 +5,11 @@ import (
"time"
"github.com/1Panel-dev/1Panel/agent/app/dto"
+ "github.com/1Panel-dev/1Panel/agent/app/repo"
"github.com/1Panel-dev/1Panel/agent/constant"
+ "github.com/1Panel-dev/1Panel/agent/global"
+ "github.com/1Panel-dev/1Panel/agent/utils/encrypt"
+ "github.com/1Panel-dev/1Panel/agent/utils/xpack"
)
type SettingService struct{}
@@ -13,6 +17,8 @@ type SettingService struct{}
type ISettingService interface {
GetSettingInfo() (*dto.SettingInfo, error)
Update(key, value string) error
+
+ ReloadConn() error
}
func NewISettingService() ISettingService {
@@ -59,3 +65,52 @@ func (u *SettingService) Update(key, value string) error {
}
return nil
}
+
+func (u *SettingService) ReloadConn() error {
+ if global.IsMaster {
+ return nil
+ }
+ isLocal, nodeInfo, err := xpack.LoadNodeInfo()
+ if err != nil {
+ global.LOG.Errorf("load new node info failed, err: %v", err)
+ return nil
+ }
+ if isLocal {
+ return nil
+ }
+
+ settingRepo := repo.NewISettingRepo()
+ itemKey, _ := encrypt.StringEncrypt(nodeInfo.ServerKey)
+ if err := settingRepo.Update("ServerKey", itemKey); err != nil {
+ global.LOG.Errorf("update server key failed, err: %v", err)
+ return nil
+ }
+ itemCrt, _ := encrypt.StringEncrypt(nodeInfo.ServerCrt)
+ if err := settingRepo.Update("ServerCrt", itemCrt); err != nil {
+ global.LOG.Errorf("update server crt failed, err: %v", err)
+ return nil
+ }
+ if err := settingRepo.Update("CurrentNode", nodeInfo.CurrentNode); err != nil {
+ global.LOG.Errorf("update current node failed, err: %v", err)
+ return nil
+ }
+ if err := settingRepo.Update("SystemVersion", nodeInfo.Version); err != nil {
+ global.LOG.Errorf("update system version failed, err: %v", err)
+ return nil
+ }
+ if err := settingRepo.Update("BaseDir", nodeInfo.BaseDir); err != nil {
+ global.LOG.Errorf("update base dir failed, err: %v", err)
+ return nil
+ }
+ if err := settingRepo.Update("MasterAddr", nodeInfo.MasterAddr); err != nil {
+ global.LOG.Errorf("update master addr failed, err: %v", err)
+ return nil
+ }
+
+ global.CONF.System.BaseDir, _ = settingRepo.GetValueByKey("BaseDir")
+ global.CONF.System.Version, _ = settingRepo.GetValueByKey("SystemVersion")
+ global.CONF.System.EncryptKey, _ = settingRepo.GetValueByKey("EncryptKey")
+ global.CONF.System.CurrentNode, _ = settingRepo.GetValueByKey("CurrentNode")
+ global.CONF.System.MasterAddr, _ = settingRepo.GetValueByKey("MasterAddr")
+ return nil
+}
diff --git a/agent/go.mod b/agent/go.mod
index acd7a5d87..bd38f9122 100644
--- a/agent/go.mod
+++ b/agent/go.mod
@@ -11,7 +11,6 @@ require (
github.com/docker/docker v27.1.0+incompatible
github.com/docker/go-connections v0.5.0
github.com/fsnotify/fsnotify v1.7.0
- github.com/gin-contrib/gzip v1.0.1
github.com/gin-gonic/gin v1.10.0
github.com/glebarez/sqlite v1.11.0
github.com/go-acme/lego/v4 v4.17.4
diff --git a/agent/go.sum b/agent/go.sum
index ef5e6a171..d7c18deaa 100644
--- a/agent/go.sum
+++ b/agent/go.sum
@@ -217,8 +217,6 @@ github.com/fvbommel/sortorder v1.0.2 h1:mV4o8B2hKboCdkJm+a7uX/SIpZob4JzUpc5GGnM4
github.com/fvbommel/sortorder v1.0.2/go.mod h1:uk88iVf1ovNn1iLfgUVU2F9o5eO30ui720w+kxuqRs0=
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
-github.com/gin-contrib/gzip v1.0.1 h1:HQ8ENHODeLY7a4g1Au/46Z92bdGFl74OhxcZble9WJE=
-github.com/gin-contrib/gzip v1.0.1/go.mod h1:njt428fdUNRvjuJf16tZMYZ2Yl+WQB53X5wmhDwXvC4=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
diff --git a/agent/init/hook/hook.go b/agent/init/hook/hook.go
index 334319afc..c1bf09c4b 100644
--- a/agent/init/hook/hook.go
+++ b/agent/init/hook/hook.go
@@ -14,7 +14,7 @@ import (
)
func Init() {
- initWithNodeJson()
+ service.NewISettingService().ReloadConn()
initGlobalData()
handleCronjobStatus()
handleSnapStatus()
diff --git a/agent/router/ro_setting.go b/agent/router/ro_setting.go
index 1247b3dcc..baa2cf270 100644
--- a/agent/router/ro_setting.go
+++ b/agent/router/ro_setting.go
@@ -14,6 +14,7 @@ func (s *SettingRouter) InitRouter(Router *gin.RouterGroup) {
settingRouter.POST("/search", baseApi.GetSettingInfo)
settingRouter.GET("/search/available", baseApi.GetSystemAvailable)
settingRouter.POST("/update", baseApi.UpdateSetting)
+ settingRouter.POST("/conn/reload", baseApi.ReloadConn)
settingRouter.GET("/snapshot/load", baseApi.LoadSnapshotData)
settingRouter.POST("/snapshot", baseApi.CreateSnapshot)
diff --git a/core/app/service/setting.go b/core/app/service/setting.go
index 92923a9a1..e270ae0a7 100644
--- a/core/app/service/setting.go
+++ b/core/app/service/setting.go
@@ -187,7 +187,7 @@ func (u *SettingService) UpdatePort(port uint) error {
if common.ScanPort(int(port)) {
return buserr.WithDetail(constant.ErrPortInUsed, port, nil)
}
- oldPort, err := settingRepo.Get(repo.WithByKey("Port"))
+ oldPort, err := settingRepo.Get(repo.WithByKey("ServerPort"))
if err != nil {
return err
}
@@ -197,6 +197,20 @@ func (u *SettingService) UpdatePort(port uint) error {
if err := firewall.UpdatePort(oldPort.Value, fmt.Sprintf("%v", port)); err != nil {
return err
}
+ masterAddr, err := settingRepo.Get(repo.WithByKey("MasterAddr"))
+ if err != nil {
+ global.LOG.Errorf("load master addr from db failed, err: %v", err)
+ return err
+ }
+ if len(masterAddr.Value) != 0 {
+ oldMasterPort := loadPort(masterAddr.Value)
+ if len(oldMasterPort) != 0 {
+ if err := xpack.UpdateMasterAddr(strings.ReplaceAll(masterAddr.Value, oldMasterPort, fmt.Sprintf("%v", port))); err != nil {
+ global.LOG.Errorf("update master addr from db failed, err: %v", err)
+ return err
+ }
+ }
+ }
if err := settingRepo.Update("ServerPort", strconv.Itoa(int(port))); err != nil {
return err
@@ -208,20 +222,6 @@ func (u *SettingService) UpdatePort(port uint) error {
global.LOG.Errorf("restart system port failed, err: %v", err)
}
}()
- masterAddr, err := settingRepo.Get(repo.WithByKey("MasterAddr"))
- if err != nil {
- global.LOG.Errorf("load master addr from db failed, err: %v", err)
- return
- }
- if len(masterAddr.Value) != 0 {
- oldMasterPort := loadPort(masterAddr.Value)
- if len(oldMasterPort) != 0 {
- if err := xpack.UpdateMasterAddr(strings.ReplaceAll(masterAddr.Value, oldMasterPort, fmt.Sprintf("%v", port))); err != nil {
- global.LOG.Errorf("update master addr from db failed, err: %v", err)
- return
- }
- }
- }
}()
return nil
}
diff --git a/core/constant/status.go b/core/constant/status.go
index 2f78fba17..cc5979fde 100644
--- a/core/constant/status.go
+++ b/core/constant/status.go
@@ -8,7 +8,6 @@ const (
StatusWaiting = "Waiting"
StatusPacking = "Packing"
StatusSending = "Sending"
- StatusChecking = "Checking"
StatusStarting = "Starting"
StatusHealthy = "Healthy"
StatusUnhealthy = "Unhealthy"
diff --git a/frontend/src/components/dialog-pro/index.vue b/frontend/src/components/dialog-pro/index.vue
new file mode 100644
index 000000000..7658a5a3a
--- /dev/null
+++ b/frontend/src/components/dialog-pro/index.vue
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/frontend/src/components/index.ts b/frontend/src/components/index.ts
index 0adf7cde3..d597ecd43 100644
--- a/frontend/src/components/index.ts
+++ b/frontend/src/components/index.ts
@@ -12,6 +12,7 @@ import CopyButton from '@/components/copy-button/index.vue';
import MsgInfo from '@/components/msg-info/index.vue';
import MainDiv from '@/components/main-div/index.vue';
import DrawerPro from '@/components/drawer-pro/index.vue';
+import DialogPro from '@/components/dialog-pro/index.vue';
export default {
install(app: App) {
app.component(LayoutContent.name, LayoutContent);
@@ -27,5 +28,6 @@ export default {
app.component(MsgInfo.name, MsgInfo);
app.component(MainDiv.name, MainDiv);
app.component(DrawerPro.name, DrawerPro);
+ app.component(DialogPro.name, DialogPro);
},
};