更新依赖和调整目录结构,未修改模块
This commit is contained in:
58
pkgs/all/cmd/main/main.go
Normal file
58
pkgs/all/cmd/main/main.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"bsm/full/pkgs/all/internal/config"
|
||||
"bsm/full/pkgs/all/internal/impl"
|
||||
allserver "bsm/full/pkgs/all/internal/server"
|
||||
"bsm/full/pkgs/all/internal/service"
|
||||
|
||||
"git.apinb.com/bsm-sdk/core/utils"
|
||||
)
|
||||
|
||||
var ServiceKey = "default"
|
||||
|
||||
func main() {
|
||||
workspace := flag.String("workspace", ServiceKey, "workspace used to select etc/{workspace}_{runtime}.yaml")
|
||||
flag.Parse()
|
||||
value, err := utils.MustString(*workspace)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
ServiceKey = value
|
||||
|
||||
config.New(ServiceKey)
|
||||
impl.NewImpl()
|
||||
|
||||
srv, err := allserver.New(
|
||||
config.Spec.Authorization.Key,
|
||||
config.Spec.Authorization.Expire,
|
||||
config.Spec.Authorization.Anonymous,
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if err := service.Expose(srv); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
stop := make(chan os.Signal, 1)
|
||||
signal.Notify(stop, syscall.SIGINT, syscall.SIGTERM)
|
||||
go func() {
|
||||
<-stop
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
_ = srv.Stop(ctx)
|
||||
}()
|
||||
|
||||
if err := srv.Start(config.Spec.Server.GRPC.Addr, config.Spec.Server.HTTP.Addr); err != nil && err != http.ErrServerClosed {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user