Ai
1 Star 0 Fork 0

csingo/cServer

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Component.go 1.41 KB
一键复制 编辑 原始数据 按行查看 历史
joe 提交于 2024-12-11 11:15 +08:00 . update
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{}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/csingo/cServer.git
git@gitee.com:csingo/cServer.git
csingo
cServer
cServer
v0.4.27

搜索帮助