代码拉取完成,页面将自动刷新
package cServer
import (
"os"
"os/signal"
"syscall"
assetfs "github.com/elazarl/go-bindata-assetfs"
"gitee.com/csingo/cComponents"
"gitee.com/csingo/cLog"
)
type ServerComponent struct{}
func (i *ServerComponent) Inject(instance any) bool {
if container.IsView(instance) {
return container.SaveView(instance.(*assetfs.AssetFS))
}
if container.Is(instance) {
return container.Save(instance)
}
return false
}
func (i *ServerComponent) InjectConf(config cComponents.ConfigInterface) bool {
var result bool
switch config.ConfigName() {
case ServerConfigName:
server_config = config.(*ServerConf)
result = true
case RouteConfigName:
route_config = config.(*RouteConf)
result = true
case ComponentsConfigName:
components_config = config.(*ComponentsConf)
result = true
}
return result
}
func (i *ServerComponent) Load() {
// 进程常驻
osch := make(chan os.Signal, 1)
signal.Notify(osch, os.Interrupt, syscall.SIGTERM)
cLog.WithContext(nil, map[string]any{
"source": "cServer.ServerComponent.Load",
}).Info("启动系统信号监听")
for { //nolint:gosimple
select {
case item := <-osch:
cLog.WithContext(nil, map[string]any{
"source": "cServer.ServerComponent.Load",
"signal": item,
}).Fatalln("捕获系统退出信号")
}
}
}
func (i *ServerComponent) Listen() []*cComponents.ConfigListener {
return []*cComponents.ConfigListener{}
}
var Component = &ServerComponent{}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。