flag를 flagx로 변경
This commit is contained in:
@ -1,15 +0,0 @@
|
||||
package flag
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
var commandLine = flag.NewFlagSet("maingate", flag.ContinueOnError)
|
||||
var Devflag = commandLine.Bool("dev", false, "")
|
||||
|
||||
func init() {
|
||||
commandLine.SetOutput(io.Discard)
|
||||
commandLine.Parse(os.Args[1:])
|
||||
}
|
||||
@ -17,9 +17,9 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"repositories.action2quare.com/ayo/gocommon/flagx"
|
||||
"repositories.action2quare.com/ayo/gocommon/logger"
|
||||
"repositories.action2quare.com/ayo/gocommon/wshandler"
|
||||
"repositories.action2quare.com/ayo/tavern/core/flag"
|
||||
"repositories.action2quare.com/ayo/tavern/core/rpc"
|
||||
|
||||
"github.com/go-redis/redis/v8"
|
||||
@ -942,6 +942,8 @@ func (gm *groupInMemory) UpdateGroupDocument(gid groupID, body []byte) error {
|
||||
return gm.groupDocSync(gid, newbody)
|
||||
}
|
||||
|
||||
var devflag = flagx.Bool("dev", false, "")
|
||||
|
||||
func (cfg *groupConfig) prepareInMemory(ctx context.Context, region string, typename string, wsh *wshandler.WebsocketHandler) (group, error) {
|
||||
// group document
|
||||
// member document
|
||||
@ -953,7 +955,7 @@ func (cfg *groupConfig) prepareInMemory(ctx context.Context, region string, type
|
||||
toHashHex := func(name string) string {
|
||||
hash := md5.New()
|
||||
hash.Write([]byte(name))
|
||||
if *flag.Devflag {
|
||||
if *devflag {
|
||||
hn, _ := os.Hostname()
|
||||
hash.Write([]byte(hn))
|
||||
}
|
||||
|
||||
2
go.mod
2
go.mod
@ -6,7 +6,7 @@ require (
|
||||
github.com/go-redis/redis/v8 v8.11.5
|
||||
github.com/gorilla/websocket v1.5.0
|
||||
go.mongodb.org/mongo-driver v1.11.7
|
||||
repositories.action2quare.com/ayo/gocommon v0.0.0-20230620085155-94b6d1499a94
|
||||
repositories.action2quare.com/ayo/gocommon v0.0.0-20230621052811-06ef97f11d22
|
||||
)
|
||||
|
||||
require (
|
||||
|
||||
2
go.sum
2
go.sum
@ -104,3 +104,5 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
repositories.action2quare.com/ayo/gocommon v0.0.0-20230620085155-94b6d1499a94 h1:0MwsZfy1DM+ABzQQ9uocN8IZRtdgwbUWwnhDbwnKJMg=
|
||||
repositories.action2quare.com/ayo/gocommon v0.0.0-20230620085155-94b6d1499a94/go.mod h1:ng62uGMGXyQSeuxePG5gJAMtip4Rnspu5Tu7hgvaXns=
|
||||
repositories.action2quare.com/ayo/gocommon v0.0.0-20230621052811-06ef97f11d22 h1:DImSGNxZrc+Q4WlS1OKMsLAScEfDYLX4XMJdjAaVnXc=
|
||||
repositories.action2quare.com/ayo/gocommon v0.0.0-20230621052811-06ef97f11d22/go.mod h1:ng62uGMGXyQSeuxePG5gJAMtip4Rnspu5Tu7hgvaXns=
|
||||
|
||||
7
main.go
7
main.go
@ -5,6 +5,7 @@ import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"repositories.action2quare.com/ayo/gocommon/flagx"
|
||||
"repositories.action2quare.com/ayo/gocommon/wshandler"
|
||||
"repositories.action2quare.com/ayo/tavern/core"
|
||||
|
||||
@ -12,6 +13,8 @@ import (
|
||||
"repositories.action2quare.com/ayo/gocommon/logger"
|
||||
)
|
||||
|
||||
var prefix = flagx.String("prefix", "", "")
|
||||
|
||||
func main() {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
var config core.TavernConfig
|
||||
@ -29,8 +32,8 @@ func main() {
|
||||
panic(err)
|
||||
} else {
|
||||
serveMux := http.NewServeMux()
|
||||
wsh.RegisterHandlers(ctx, serveMux, *common.PrefixPtr)
|
||||
tv.RegisterHandlers(ctx, serveMux, *common.PrefixPtr)
|
||||
wsh.RegisterHandlers(ctx, serveMux, *prefix)
|
||||
tv.RegisterHandlers(ctx, serveMux, *prefix)
|
||||
server := common.NewHTTPServer(serveMux)
|
||||
logger.Println("tavern is started")
|
||||
server.Start()
|
||||
|
||||
Reference in New Issue
Block a user