fix issues
This commit is contained in:
12
cmd_root.go
12
cmd_root.go
@@ -65,7 +65,17 @@ func LoadProviders(cfgFile, appName string, providers container.Providers) error
|
|||||||
|
|
||||||
type Option func(*cobra.Command)
|
type Option func(*cobra.Command)
|
||||||
|
|
||||||
var AppName string
|
var (
|
||||||
|
AppName string
|
||||||
|
AppVersion string
|
||||||
|
)
|
||||||
|
|
||||||
|
func Version(ver string) Option {
|
||||||
|
return func(cmd *cobra.Command) {
|
||||||
|
cmd.Version = ver
|
||||||
|
AppVersion = ver
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func Name(name string) Option {
|
func Name(name string) Option {
|
||||||
return func(cmd *cobra.Command) {
|
return func(cmd *cobra.Command) {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package container
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
@@ -20,7 +21,8 @@ var (
|
|||||||
func init() {
|
func init() {
|
||||||
closeable = make([]func(), 0)
|
closeable = make([]func(), 0)
|
||||||
if err := Container.Provide(func() context.Context {
|
if err := Container.Provide(func() context.Context {
|
||||||
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
|
signals := []os.Signal{syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGKILL}
|
||||||
|
ctx, cancel := signal.NotifyContext(context.Background(), signals...)
|
||||||
go func() {
|
go func() {
|
||||||
<-ctx.Done()
|
<-ctx.Done()
|
||||||
Close()
|
Close()
|
||||||
|
|||||||
Reference in New Issue
Block a user