示例#1
0
        public static void Main(string[] args)
        {
            // See https://support.microsoft.com/en-gb/help/821268/contention-poor-performance-and-deadlocks-when-you-make-calls-to-web-s
            // Experimentation shows we need the ThreadPool to always spin up threads for good performance under load
            ThreadPool.GetMaxThreads(out var workerThreads, out var ioThreads);
            ThreadPool.SetMinThreads(workerThreads, ioThreads);

            Parser.Default.ParseArguments <PartyServerCommandLineArgs>(args)
            .WithParsed(parsedArgs =>
            {
                parsedArgs.Validate();

                var spatialRefreshToken = Secrets.GetEnvSecret(SpatialRefreshTokenEnvironmentVariable);

                PartyDataModel.Defaults.MinMembers = (uint)parsedArgs.DefaultMinMembers;
                PartyDataModel.Defaults.MaxMembers = (uint)parsedArgs.DefaultMaxMembers;

                Log.Logger = new LoggerConfiguration()
                             .WriteTo.Console(new RenderedCompactJsonFormatter())
                             .Enrich.FromLogContext()
                             .CreateLogger();

                using (var server = GrpcBaseServer.Build(parsedArgs))
                    using (var memoryStoreManager = new RedisClientManager(parsedArgs.RedisConnectionString))
                    {
                        Log.Information($"Successfully connected to Redis at {parsedArgs.RedisConnectionString}");
                        server.AddInterceptor(new PlayerIdentityTokenValidatingInterceptor(
                                                  PlayerAuthServiceClient.Create(credentials: new PlatformRefreshTokenCredential(spatialRefreshToken)),
                                                  memoryStoreManager.GetRawClient(Database.CACHE)
                                                  ))
                        .AddInterceptor(new ExceptionMappingInterceptor(new Dictionary <Type, StatusCode>
                        {
                            { typeof(EntryNotFoundException), StatusCode.NotFound },
                            { typeof(EntryAlreadyExistsException), StatusCode.AlreadyExists },
                            { typeof(TransactionAbortedException), StatusCode.Unavailable }
                        }));
                        server.AddService(
                            PartyService.BindService(new PartyServiceImpl(memoryStoreManager)));
                        server.AddService(
                            InviteService.BindService(new InviteServiceImpl(memoryStoreManager)));
                        var serverTask = Task.Run(() => server.Start());
                        var signalTask = Task.Run(() => UnixSignal.WaitAny(new[] { new UnixSignal(Signum.SIGINT), new UnixSignal(Signum.SIGTERM) }));
                        Task.WaitAny(serverTask, signalTask);

                        if (signalTask.IsCompleted)
                        {
                            Log.Information($"Received UNIX signal {signalTask.Result}");
                            Log.Information("Server shutting down...");
                            server.Shutdown();
                            serverTask.Wait();
                            Log.Information("Server stopped cleanly");
                        }
                        else
                        {
                            /* The server task has completed; we can just exit. */
                            Log.Information("The Party server has stopped itself or encountered an unhandled exception.");
                        }
                    }
            });
        }
示例#2
0
        public static void Main(string[] args)
        {
            // See https://support.microsoft.com/en-gb/help/821268/contention-poor-performance-and-deadlocks-when-you-make-calls-to-web-s
            // Experimentation shows we need the ThreadPool to always spin up threads for good performance under load
            ThreadPool.GetMaxThreads(out var workerThreads, out var ioThreads);
            ThreadPool.SetMinThreads(workerThreads, ioThreads);

            Parser.Default.ParseArguments <PlayFabAuthArguments>(args)
            .WithParsed(parsedArgs =>
            {
                Log.Logger = new LoggerConfiguration()
                             .WriteTo.Console(new RenderedCompactJsonFormatter())
                             .Enrich.FromLogContext()
                             .CreateLogger();
                //spatial service account token i set up and entered into kubernets
                var spatialRefreshToken = Secrets.GetEnvSecret(SpatialRefreshTokenEnvironmentVariable).Trim();
                var playfabDeveloperKey = Secrets.GetEnvSecret(PlayFabSecretKeyEnvironmentVariable).Trim();

                PlayFabSettings.DeveloperSecretKey = playfabDeveloperKey;
                PlayFabSettings.TitleId            = parsedArgs.PlayFabTitleId;

                IAnalyticsSender analyticsSender = new AnalyticsSenderBuilder("playfab_auth")
                                                   .WithCommandLineArgs(parsedArgs)
                                                   .With(new LogExceptionStrategy(Log.Logger))
                                                   .Build();


                var server = GrpcBaseServer.Build(parsedArgs);
                server.AddService(AuthService.BindService(
                                      new PlayFabAuthImpl(
                                          parsedArgs.SpatialProject,
                                          PlayerAuthServiceClient.Create(
                                              /*endpoint: new PlatformApiEndpoint("playerauth.api.improbable.io", 443),*/
                                              credentials: new PlatformRefreshTokenCredential(spatialRefreshToken)),
                                          analyticsSender)
                                      ));

                var serverTask = Task.Run(() => server.Start());
                var signalTask = Task.Run(() => UnixSignal.WaitAny(new[] { new UnixSignal(Signum.SIGINT), new UnixSignal(Signum.SIGTERM) }));
                Log.Information("PlayFab authentication server started up");
                Task.WaitAny(serverTask, signalTask);

                if (signalTask.IsCompleted)
                {
                    Log.Information($"Received UNIX signal {signalTask.Result}");
                    Log.Information("Server shutting down...");
                    server.Shutdown();
                    serverTask.Wait();
                    Log.Information("Server stopped cleanly");
                }
                else
                {
                    /* The server task has completed; we can just exit. */
                    Log.Information("The PlayFab authentication server has stopped itself or encountered an unhandled exception.");
                }

                Environment.Exit(0);
            });
        }
示例#3
0
        public static void Main(string[] args)
        {
            // See https://support.microsoft.com/en-gb/help/821268/contention-poor-performance-and-deadlocks-when-you-make-calls-to-web-s
            // Experimentation shows we need the ThreadPool to always spin up threads for good performance under load
            ThreadPool.GetMaxThreads(out var workerThreads, out var ioThreads);
            ThreadPool.SetMinThreads(workerThreads, ioThreads);

            Parser.Default.ParseArguments <SteamAuthArguments>(args)
            .WithParsed(parsedArgs =>
            {
                Log.Logger = new LoggerConfiguration()
                             .WriteTo.Console(new RenderedCompactJsonFormatter())
                             .Enrich.FromLogContext()
                             .CreateLogger();

                var steamDeveloperKey = Secrets.GetEnvSecret(SteamSymmetricKey).Trim();


                var server = GrpcBaseServer.Build(parsedArgs);
                server.AddService
                (
                    AuthService.BindService
                    (
                        new SteamAuthImpl
                        (
                            parsedArgs.ProjectName,
                            PlayerAuthServiceClient.Create
                            (
                                endpoint: new PlatformApiEndpoint(/*host*/ "steamauth.api.com", /*pot*/ 443, /*insecure*/ true),
                                credentials: null, //new PlatformRefreshTokenCredential()
                                settings: null
                            ),
                            analytics: null
                        )
                    )
                );

                var serverTask = Task.Run(() => server.Start());
                var signalTask = Task.Run(() => UnixSignal.WaitAny(new[] { new UnixSignal(Signum.SIGINT), new UnixSignal(Signum.SIGTERM) }));
                Log.Information("Steam authentication server started up");
                Task.WaitAny(serverTask, signalTask);

                if (signalTask.IsCompleted)
                {
                    Log.Information($"Received UNIX signal {signalTask.Result}");
                    Log.Information("Server shutting down...");
                    server.Shutdown();
                    serverTask.Wait();
                    Log.Information("Server stopped cleanly");
                }
                else
                {
                    /* The server task has completed; we can just exit. */
                    Log.Information("The PlayFab authentication server has stopped itself or encountered an unhandled exception.");
                }

                Environment.Exit(0);
            });
        }
示例#4
0
        static void Main(string[] args)
        {
            Log.Logger = new LoggerConfiguration()
                         .WriteTo.Console(new RenderedCompactJsonFormatter())
                         .Enrich.FromLogContext()
                         .CreateLogger();

            // See https://support.microsoft.com/en-gb/help/821268/contention-poor-performance-and-deadlocks-when-you-make-calls-to-web-s
            // Experimentation shows we need the ThreadPool to always spin up threads for good performance under load
            ThreadPool.GetMaxThreads(out var workerThreads, out var ioThreads);
            ThreadPool.SetMinThreads(workerThreads, ioThreads);

            Parser.Default.ParseArguments <GatewayArgs>(args)
            .WithParsed(parsedArgs =>
            {
                var spatialRefreshToken = Secrets.GetEnvSecret(SpatialRefreshTokenEnvironmentVariable);

                var memoryStoreClientManager =
                    new RedisClientManager(parsedArgs.RedisConnectionString);

                var playerAuthClient =
                    PlayerAuthServiceClient.Create(
                        credentials: new PlatformRefreshTokenCredential(spatialRefreshToken));

                IAnalyticsSender analyticsSender = new AnalyticsSenderBuilder("gateway_gateway")
                                                   .WithCommandLineArgs(parsedArgs)
                                                   .With(new LogExceptionStrategy(Log.Logger))
                                                   .Build();

                var server = GrpcBaseServer.Build(parsedArgs);
                server.AddInterceptor(new PlayerIdentityTokenValidatingInterceptor(
                                          playerAuthClient,
                                          memoryStoreClientManager.GetRawClient(Database.CACHE)));
                server.AddService(
                    GatewayService.BindService(new GatewayServiceImpl(memoryStoreClientManager, playerAuthClient, analyticsSender)));

                var serverTask = Task.Run(() => server.Start());
                var signalTask = Task.Run(() => UnixSignal.WaitAny(new[] { new UnixSignal(Signum.SIGINT), new UnixSignal(Signum.SIGTERM) }));
                Task.WaitAny(serverTask, signalTask);

                if (signalTask.IsCompleted)
                {
                    Log.Information($"Received UNIX signal {signalTask.Result}");
                    Log.Information("Server shutting down...");
                    server.Shutdown();
                    serverTask.Wait();
                    Log.Information("Server stopped cleanly");
                }
                else
                {
                    /* The server task has completed; we can just exit. */
                    Log.Information("The Gateway server has stopped itself or encountered an unhandled exception.");
                }
            });
        }
示例#5
0
        static void Main(string[] args)
        {
            // See https://support.microsoft.com/en-gb/help/821268/contention-poor-performance-and-deadlocks-when-you-make-calls-to-web-s
            // Experimentation shows we need the ThreadPool to always spin up threads for good performance under load
            ThreadPool.GetMaxThreads(out var workerThreads, out var ioThreads);
            ThreadPool.SetMinThreads(workerThreads, ioThreads);

            Parser.Default.ParseArguments <GatewayInternalArgs>(args)
            .WithParsed(parsedArgs =>
            {
                Log.Logger = new LoggerConfiguration()
                             .WriteTo.Console(new RenderedCompactJsonFormatter())
                             .Enrich.FromLogContext()
                             .CreateLogger();

                var memoryStoreClientManager = new RedisClientManager(parsedArgs.RedisConnectionString);

                var server = GrpcBaseServer.Build(parsedArgs);
                server.AddService(
                    GatewayInternalService.BindService(new GatewayInternalServiceImpl(memoryStoreClientManager)));

                var serverTask = Task.Run(() => server.Start());
                var signalTask = Task.Run(() => UnixSignal.WaitAny(new[] { new UnixSignal(Signum.SIGINT), new UnixSignal(Signum.SIGTERM) }));
                Task.WaitAny(serverTask, signalTask);

                if (signalTask.IsCompleted)
                {
                    Log.Information($"Received UNIX signal {signalTask.Result}");
                    Log.Information("Server shutting down...");
                    server.Shutdown();
                    serverTask.Wait();
                    Log.Information("Server stopped cleanly");
                }
                else
                {
                    /* The server task has completed; we can just exit. */
                    Log.Information("The GatewayInternal server has stopped itself or encountered an unhandled exception.");
                }
            });
        }