This commit is contained in:
lu.bai
2022-11-24 23:29:33 +08:00
parent 71d0135d6f
commit 48d5291b33
18 changed files with 445 additions and 191 deletions

23
cmd/hk4e/dispatch.go Normal file
View File

@@ -0,0 +1,23 @@
package main
import (
"context"
"hk4e/dispatch/app"
"github.com/spf13/cobra"
)
// DispatchCmd
func DispatchCmd() *cobra.Command {
var cfg string
c := &cobra.Command{
Use: "dispatch",
Short: "dispatch server",
RunE: func(cmd *cobra.Command, args []string) error {
return app.Run(context.Background(), cfg)
},
}
c.Flags().StringVar(&cfg, "config", "application.toml", "config file")
return c
}

23
cmd/hk4e/gate.go Normal file
View File

@@ -0,0 +1,23 @@
package main
import (
"context"
"hk4e/gate/app"
"github.com/spf13/cobra"
)
// GateCmd 检查配表命令
func GateCmd() *cobra.Command {
var cfg string
c := &cobra.Command{
Use: "gate",
Short: "gate server",
RunE: func(cmd *cobra.Command, args []string) error {
return app.Run(context.Background(), cfg)
},
}
c.Flags().StringVar(&cfg, "config", "application.toml", "config file")
return c
}

23
cmd/hk4e/gm.go Normal file
View File

@@ -0,0 +1,23 @@
package main
import (
"context"
"hk4e/gm/app"
"github.com/spf13/cobra"
)
// GMCmd
func GMCmd() *cobra.Command {
var cfg string
c := &cobra.Command{
Use: "gm",
Short: "gm server",
RunE: func(cmd *cobra.Command, args []string) error {
return app.Run(context.Background(), cfg)
},
}
c.Flags().StringVar(&cfg, "config", "application.toml", "config file")
return c
}

23
cmd/hk4e/gs.go Normal file
View File

@@ -0,0 +1,23 @@
package main
import (
"context"
"hk4e/gs/app"
"github.com/spf13/cobra"
)
// GSCmd
func GSCmd() *cobra.Command {
var cfg string
c := &cobra.Command{
Use: "gs",
Short: "game server",
RunE: func(cmd *cobra.Command, args []string) error {
return app.Run(context.Background(), cfg)
},
}
c.Flags().StringVar(&cfg, "config", "application.toml", "config file")
return c
}

33
cmd/hk4e/main.go Normal file
View File

@@ -0,0 +1,33 @@
package main
import (
"flag"
"fmt"
_ "net/http/pprof"
"os"
"github.com/spf13/cobra"
)
var (
config = flag.String("config", "application.toml", "config file")
)
func main() {
rootCmd := &cobra.Command{
Use: "hk4e",
Short: "hk4e server",
SilenceUsage: true,
}
rootCmd.AddCommand(
GSCmd(),
GMCmd(),
DispatchCmd(),
GateCmd(),
)
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}