flag를 flagx로 변경

This commit is contained in:
2023-06-21 14:38:26 +09:00
parent ed905a3722
commit 667126c5bc
5 changed files with 12 additions and 20 deletions

View File

@ -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:])
}

View File

@ -17,9 +17,9 @@ import (
"sync" "sync"
"time" "time"
"repositories.action2quare.com/ayo/gocommon/flagx"
"repositories.action2quare.com/ayo/gocommon/logger" "repositories.action2quare.com/ayo/gocommon/logger"
"repositories.action2quare.com/ayo/gocommon/wshandler" "repositories.action2quare.com/ayo/gocommon/wshandler"
"repositories.action2quare.com/ayo/tavern/core/flag"
"repositories.action2quare.com/ayo/tavern/core/rpc" "repositories.action2quare.com/ayo/tavern/core/rpc"
"github.com/go-redis/redis/v8" "github.com/go-redis/redis/v8"
@ -942,6 +942,8 @@ func (gm *groupInMemory) UpdateGroupDocument(gid groupID, body []byte) error {
return gm.groupDocSync(gid, newbody) 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) { func (cfg *groupConfig) prepareInMemory(ctx context.Context, region string, typename string, wsh *wshandler.WebsocketHandler) (group, error) {
// group document // group document
// member document // member document
@ -953,7 +955,7 @@ func (cfg *groupConfig) prepareInMemory(ctx context.Context, region string, type
toHashHex := func(name string) string { toHashHex := func(name string) string {
hash := md5.New() hash := md5.New()
hash.Write([]byte(name)) hash.Write([]byte(name))
if *flag.Devflag { if *devflag {
hn, _ := os.Hostname() hn, _ := os.Hostname()
hash.Write([]byte(hn)) hash.Write([]byte(hn))
} }

2
go.mod
View File

@ -6,7 +6,7 @@ require (
github.com/go-redis/redis/v8 v8.11.5 github.com/go-redis/redis/v8 v8.11.5
github.com/gorilla/websocket v1.5.0 github.com/gorilla/websocket v1.5.0
go.mongodb.org/mongo-driver v1.11.7 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 ( require (

2
go.sum
View File

@ -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= 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 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-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=

View File

@ -5,6 +5,7 @@ import (
"context" "context"
"net/http" "net/http"
"repositories.action2quare.com/ayo/gocommon/flagx"
"repositories.action2quare.com/ayo/gocommon/wshandler" "repositories.action2quare.com/ayo/gocommon/wshandler"
"repositories.action2quare.com/ayo/tavern/core" "repositories.action2quare.com/ayo/tavern/core"
@ -12,6 +13,8 @@ import (
"repositories.action2quare.com/ayo/gocommon/logger" "repositories.action2quare.com/ayo/gocommon/logger"
) )
var prefix = flagx.String("prefix", "", "")
func main() { func main() {
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
var config core.TavernConfig var config core.TavernConfig
@ -29,8 +32,8 @@ func main() {
panic(err) panic(err)
} else { } else {
serveMux := http.NewServeMux() serveMux := http.NewServeMux()
wsh.RegisterHandlers(ctx, serveMux, *common.PrefixPtr) wsh.RegisterHandlers(ctx, serveMux, *prefix)
tv.RegisterHandlers(ctx, serveMux, *common.PrefixPtr) tv.RegisterHandlers(ctx, serveMux, *prefix)
server := common.NewHTTPServer(serveMux) server := common.NewHTTPServer(serveMux)
logger.Println("tavern is started") logger.Println("tavern is started")
server.Start() server.Start()