2023-02-02 07:01:37 +00:00
|
|
|
package hook
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/1Panel-dev/1Panel/backend/app/repo"
|
|
|
|
"github.com/1Panel-dev/1Panel/backend/global"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Init() {
|
|
|
|
settingRepo := repo.NewISettingRepo()
|
|
|
|
portSetting, err := settingRepo.Get(settingRepo.WithByKey("ServerPort"))
|
|
|
|
if err != nil {
|
|
|
|
global.LOG.Errorf("load service port from setting failed, err: %v", err)
|
|
|
|
}
|
|
|
|
global.CONF.System.Port = portSetting.Value
|
2023-02-13 03:04:14 +00:00
|
|
|
enptrySetting, err := settingRepo.Get(settingRepo.WithByKey("EncryptKey"))
|
|
|
|
if err != nil {
|
|
|
|
global.LOG.Errorf("load service encrypt key from setting failed, err: %v", err)
|
|
|
|
}
|
|
|
|
global.CONF.System.EncryptKey = enptrySetting.Value
|
2023-02-02 07:01:37 +00:00
|
|
|
|
|
|
|
if _, err := settingRepo.Get(settingRepo.WithByKey("SystemStatus")); err != nil {
|
|
|
|
_ = settingRepo.Create("SystemStatus", "Free")
|
|
|
|
}
|
|
|
|
if err := settingRepo.Update("SystemStatus", "Free"); err != nil {
|
|
|
|
global.LOG.Fatalf("init service before start failed, err: %v", "Free")
|
|
|
|
}
|
|
|
|
}
|