초기 커밋. 친구 초대 및 관리 완료
This commit is contained in:
51
main.go
Normal file
51
main.go
Normal file
@ -0,0 +1,51 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"repositories.action2quare.com/ayo/gocommon/flagx"
|
||||
"repositories.action2quare.com/ayo/gocommon/wshandler"
|
||||
"repositories.action2quare.com/ayo/social/core"
|
||||
|
||||
"repositories.action2quare.com/ayo/gocommon"
|
||||
"repositories.action2quare.com/ayo/gocommon/logger"
|
||||
"repositories.action2quare.com/ayo/gocommon/session"
|
||||
)
|
||||
|
||||
var prefix = flagx.String("prefix", "", "")
|
||||
|
||||
func main() {
|
||||
flagx.Parse()
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
var config core.SocialConfig
|
||||
if err := gocommon.LoadConfig(&config); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
consumer, err := session.NewConsumerWithConfig(ctx, config.SessionConfig)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
wsh, err := wshandler.NewWebsocketHandler(consumer, config.RedisURL)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if so, err := core.New(ctx, wsh, &config); err != nil {
|
||||
panic(err)
|
||||
} else {
|
||||
serveMux := http.NewServeMux()
|
||||
wsh.RegisterHandlers(serveMux, *prefix)
|
||||
so.RegisterHandlers(ctx, serveMux, *prefix)
|
||||
server := gocommon.NewHTTPServer(serveMux)
|
||||
logger.Println("social is started")
|
||||
wsh.Start(ctx)
|
||||
server.Start()
|
||||
cancel()
|
||||
so.Cleanup()
|
||||
wsh.Cleanup()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user