1 parent
b365c2535f
commit
64749a578b
11 files changed
+43
-29
No files matched your search
+12
-1
@@ -12,10 +12,12 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
)
|
||||
|
||||
var IsInit bool
|
||||
var legacyInitState atomic.Bool
|
||||
var DevelopmentMode bool
|
||||
|
||||
type Config struct {
|
||||
@@ -197,7 +199,7 @@ func Init() error {
|
||||
Instance.Domains = []string{Instance.Domain}
|
||||
}
|
||||
|
||||
IsInit = Instance.IsSetupReady()
|
||||
SetInitState(Instance.IsSetupReady())
|
||||
PublishConfigSnapshot(Instance)
|
||||
|
||||
// 设置日志格式为json格式
|
||||
@@ -238,6 +240,15 @@ func (c *Config) IsSetupReady() bool {
|
||||
return c != nil && c.SetupState == SetupStateReady
|
||||
}
|
||||
|
||||
func SetInitState(value bool) {
|
||||
legacyInitState.Store(value)
|
||||
IsInit = value
|
||||
}
|
||||
|
||||
func legacyInitReady() bool {
|
||||
return legacyInitState.Load()
|
||||
}
|
||||
|
||||
func ReadPrivateKey() (*ecdsa.PrivateKey, bool, error) {
|
||||
privateKey, created, err := loadOrCreateACMEPrivateKey(filepath.Join(ROOT_PATH, "config", "ssl"), "account_private.pem")
|
||||
if err != nil {
|
||||
|
||||
@@ -16,7 +16,7 @@ func IsSetupReady() bool {
|
||||
if value != nil && value.SetupState.Valid() {
|
||||
return value.SetupState == SetupStateReady
|
||||
}
|
||||
return IsInit
|
||||
return legacyInitReady()
|
||||
}
|
||||
|
||||
// PublishConfigSnapshot 发布一份深拷贝,供运行时只读访问。
|
||||
|
||||
Reference in new issue
Block a user