mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-01-23 02:34:42 +00:00
Update server HTTPS configuration (#337)
* Merge HTTP and HTTPS routes builder in coordinator * Extract HTTP/S routes * Rename config in coordinator * Generalize child services * Extract games library helper function * Use string address instead of port for HTTP/S * Use a dedicated port extractor function * Add missing GA tag templating * Rename shared server address and port params * Introduce TLS config parameters * Simplify HTTP/S server constructors * Update server auto port roll * Extract init function in worker * Reorder return params of address type port fn * Refactor config handler names * Update TLS default config params * Extract HTTP to HTTPS redirect function * Use httpx in monitoring * Don't log echo requests * Remove error return from the abstract server * Add WSS option to the worker-coordinator connection * Change default worker config * Make worker send its internal connection params * Decouple gamelib from the coordinator * Expose HTTP/S listener address * Keep original HTTP/S addresses * Remove no config handler in worker * Use HTTP-HTTPS redirection * Wrap net.Listener into a struct * Clean http server creation fn * Redirect to https with a generated address * Use URL in the redirector * Use zone address param in worker * Make use of actual addr and port in the monitoring servers * Use auto-justified monitoring addresses info * Add the non-HTTPS worker to HTTPS coordinator connection warning * Embed TLS struct * Move connection API struct into cws package
This commit is contained in:
parent
2657dfbc70
commit
431d215eee
34 changed files with 952 additions and 658 deletions
|
|
@ -4,13 +4,11 @@ import (
|
|||
"context"
|
||||
goflag "flag"
|
||||
"math/rand"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
config "github.com/giongto35/cloud-game/v2/pkg/config/coordinator"
|
||||
"github.com/giongto35/cloud-game/v2/pkg/coordinator"
|
||||
"github.com/giongto35/cloud-game/v2/pkg/os"
|
||||
"github.com/giongto35/cloud-game/v2/pkg/util/logging"
|
||||
"github.com/golang/glog"
|
||||
flag "github.com/spf13/pflag"
|
||||
|
|
@ -18,9 +16,11 @@ import (
|
|||
|
||||
var Version = ""
|
||||
|
||||
func main() {
|
||||
func init() {
|
||||
rand.Seed(time.Now().UTC().UnixNano())
|
||||
}
|
||||
|
||||
func main() {
|
||||
conf := config.NewConfig()
|
||||
flag.CommandLine.AddGoFlagSet(goflag.CommandLine)
|
||||
conf.ParseFlags()
|
||||
|
|
@ -28,29 +28,13 @@ func main() {
|
|||
logging.Init()
|
||||
defer logging.Flush()
|
||||
|
||||
ctx, cancelCtx := context.WithCancel(context.Background())
|
||||
|
||||
glog.Infof("[coordinator] version: %v", Version)
|
||||
glog.Infof("Initializing coordinator server")
|
||||
glog.V(4).Infof("Coordinator configs %v", conf)
|
||||
app := coordinator.New(ctx, conf)
|
||||
if err := app.Run(); err != nil {
|
||||
glog.Errorf("Failed to run coordinator server, reason %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
c := coordinator.New(conf)
|
||||
c.Start()
|
||||
|
||||
signals := make(chan os.Signal, 1)
|
||||
done := make(chan struct{}, 1)
|
||||
|
||||
signal.Notify(signals, os.Interrupt, syscall.SIGTERM)
|
||||
|
||||
go func() {
|
||||
sig := <-signals
|
||||
glog.V(4).Infof("[coordinator] Shutting down [os:%v]", sig)
|
||||
done <- struct{}{}
|
||||
}()
|
||||
|
||||
<-done
|
||||
app.Shutdown()
|
||||
ctx, cancelCtx := context.WithCancel(context.Background())
|
||||
defer c.Shutdown(ctx)
|
||||
<-os.ExpectTermination()
|
||||
cancelCtx()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,12 +4,10 @@ import (
|
|||
"context"
|
||||
goflag "flag"
|
||||
"math/rand"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
config "github.com/giongto35/cloud-game/v2/pkg/config/worker"
|
||||
"github.com/giongto35/cloud-game/v2/pkg/os"
|
||||
"github.com/giongto35/cloud-game/v2/pkg/thread"
|
||||
"github.com/giongto35/cloud-game/v2/pkg/util/logging"
|
||||
"github.com/giongto35/cloud-game/v2/pkg/worker"
|
||||
|
|
@ -31,27 +29,14 @@ func run() {
|
|||
logging.Init()
|
||||
defer logging.Flush()
|
||||
|
||||
ctx, cancelCtx := context.WithCancel(context.Background())
|
||||
|
||||
glog.Infof("[worker] version: %v", Version)
|
||||
glog.V(4).Info("[worker] Initialization")
|
||||
glog.V(4).Infof("[worker] Local configuration %+v", conf)
|
||||
app := worker.New(ctx, conf)
|
||||
app.Run()
|
||||
wrk := worker.New(conf)
|
||||
wrk.Start()
|
||||
|
||||
signals := make(chan os.Signal, 1)
|
||||
done := make(chan struct{}, 1)
|
||||
|
||||
signal.Notify(signals, os.Interrupt, syscall.SIGTERM)
|
||||
|
||||
go func() {
|
||||
sig := <-signals
|
||||
glog.V(4).Infof("[worker] Shutting down [os:%v]", sig)
|
||||
done <- struct{}{}
|
||||
}()
|
||||
|
||||
<-done
|
||||
app.Shutdown()
|
||||
ctx, cancelCtx := context.WithCancel(context.Background())
|
||||
defer wrk.Shutdown(ctx)
|
||||
<-os.ExpectTermination()
|
||||
cancelCtx()
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue