mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-07-19 01:24:26 +00:00
* Disable CGO (C libs) for coordinator Needed for static linking. * Fix "error strings should not be capitalized (ST1005)" * Fix SA1015 Using time.Tick leaks the underlying ticker, consider using it only in endless functions, tests and the main package, and use time.NewTicker here (SA1015) * Fix SA9004 Only the first constant in this group has an explicit type (SA9004). * Remove unused code in the webrtc package * Fix S1000 Should use a simple channel send/receive instead of select with a single case (S1000). * Force dir creation/check for core downloader * Update Makefile release script * Disable ASLR for worker builds * Remove WORKER_BUILD_PARAMS flag from the CI * Don't force recompilation in release * Add Debian packages installer script * Build worker app without libopusfile * Test worker app without libopusfile * Add opus wrapper without opusfile * Make install.sh executable * Add opus lib in Win builds * Make insecure HTTPS requests when downloading libs * Add ca-certificates for Docker build stage go mod download works only with SSL certificates installed. * Move libx264 wrapper into the repo That way we can get rid of a lot of not needed external Go dependencies. * Update the dependencies
57 lines
1.1 KiB
Go
57 lines
1.1 KiB
Go
package main
|
|
|
|
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/thread"
|
|
"github.com/giongto35/cloud-game/v2/pkg/util/logging"
|
|
"github.com/giongto35/cloud-game/v2/pkg/worker"
|
|
"github.com/golang/glog"
|
|
flag "github.com/spf13/pflag"
|
|
)
|
|
|
|
func init() {
|
|
rand.Seed(time.Now().UTC().UnixNano())
|
|
}
|
|
|
|
func run() {
|
|
conf := config.NewConfig()
|
|
flag.CommandLine.AddGoFlagSet(goflag.CommandLine)
|
|
conf.ParseFlags()
|
|
|
|
logging.Init()
|
|
defer logging.Flush()
|
|
|
|
ctx, cancelCtx := context.WithCancel(context.Background())
|
|
|
|
glog.V(4).Info("[worker] Initialization")
|
|
glog.V(4).Infof("[worker] Local configuration %+v", conf)
|
|
wrk := worker.New(ctx, conf)
|
|
wrk.Run()
|
|
|
|
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
|
|
wrk.Shutdown()
|
|
cancelCtx()
|
|
}
|
|
|
|
func main() {
|
|
thread.MainWrapMaybe(run)
|
|
}
|