public IEnumerator ShutdownServer(ShutdownServerRequest shutdownServerRequest, string accessToken, ResultCallback callback) { Assert.IsNotNull(shutdownServerRequest, "Register failed. shutdownServerNotif is null!"); Assert.IsNotNull(accessToken, "Can't update a slot! accessToken parameter is null!"); if (this.serverType != ServerType.CLOUDSERVER) { callback.TryError(ErrorCode.Conflict, "Server not registered as Cloud Server."); yield break; } shutdownServerRequest.pod_name = serverSetup.pod_name; var request = HttpRequestBuilder.CreatePost(this.baseUrl + "/namespaces/{namespace}/servers/shutdown") .WithPathParam("namespace", this.namespace_) .WithBearerAuth(accessToken) .WithContentType(MediaType.ApplicationJson) .Accepts(MediaType.ApplicationJson) .WithBody(shutdownServerRequest.ToUtf8Json()) .GetResult(); IHttpResponse response = null; yield return(this.httpClient.SendRequest(request, rsp => response = rsp)); var result = response.TryParse(); serverType = ServerType.NONE; callback.Try(result); }
// Command line options for the automated test harness. static void ParseCommandLine(string[] args) { // Check for --delay option. int delayMs = 0; for (int i = 0; i < args.Length; ++i) { if (args[i] == "--delay") { delayMs = 1000; if (i + 1 < args.Length) { int tempVal = Convert.ToInt32(args[i + 1]); if (tempVal > 0) { delayMs = tempVal; i++; } } } } if (delayMs > 0) { System.Console.WriteLine("Delaying client: " + delayMs.ToString() + " ms."); System.Threading.Thread.Sleep(delayMs); } // Check for --shutdown option. bool shouldShutdownServer = false; for (int i = 0; i < args.Length; i++) { if (args[i] == "--shutdown") { shouldShutdownServer = true; } } if (shouldShutdownServer) { System.Console.WriteLine("Sending shutdown request to server."); RCFProto.Init(); RcfProtoChannel channel = new RcfProtoChannel(new TcpEndpoint("127.0.0.1", 50001)); RcfProtoController rcfController = new RcfProtoController(); SearchService.Stub searchService = new SearchService.Stub(channel); ShutdownServerRequest shutdownRequest = ShutdownServerRequest.CreateBuilder().Build(); searchService.ShutdownServer(null, shutdownRequest, null); // Give the server some time to shutdown. System.Threading.Thread.Sleep(1000); Environment.Exit(0); } }
public override void ShutdownServer( Google.ProtocolBuffers.IRpcController controller, ShutdownServerRequest request, System.Action <ShutdownServerResponse> done) { PrintRequest(controller, request); ShutdownEvent.Set(); ShutdownServerResponse response = ShutdownServerResponse.CreateBuilder().Build(); PrintResponse(response); done(response); }
public IEnumerator ShutdownServer(ShutdownServerRequest shutdownServerRequest, string accessToken, ResultCallback callback) { if (IsCurrentProvider(Provider.AGONES) && serverType != ServerType.LOCALSERVER) { #if ENABLE_AGONES_PLUGIN yield return(ShutdownAgones(callback)); #else callback.TryError(ErrorCode.NotFound, "Can't request shutdown server. Agones provider arguments is passed but Agones plugin is not found."); #endif yield break; } Assert.IsNotNull(shutdownServerRequest, "Register failed. shutdownServerNotif is null!"); Assert.IsNotNull(accessToken, "Can't update a slot! accessToken parameter is null!"); if (this.serverType != ServerType.CLOUDSERVER) { callback.TryError(ErrorCode.Conflict, "Server not registered as Cloud Server."); yield break; } shutdownServerRequest.pod_name = serverSetup.pod_name; var request = HttpRequestBuilder.CreatePost(this.dsmServerUrl + "/dsm/namespaces/{namespace}/servers/shutdown") .WithPathParam("namespace", this.namespace_) .WithBearerAuth(accessToken) .WithContentType(MediaType.ApplicationJson) .Accepts(MediaType.ApplicationJson) .WithBody(shutdownServerRequest.ToUtf8Json()) .GetResult(); IHttpResponse response = null; yield return(this.httpWorker.SendRequest(request, rsp => response = rsp)); var result = response.TryParse(); serverType = ServerType.NONE; callback.Try(result); }
public IEnumerator ShutdownServer(ShutdownServerRequest shutdownServerRequest, string accessToken, ResultCallback callback) { Assert.IsNotNull(shutdownServerRequest, "Register failed. shutdownServerNotif is null!"); Assert.IsNotNull(accessToken, "Can't update a slot! accessToken parameter is null!"); var request = HttpRequestBuilder.CreatePost(this.baseUrl + "/namespaces/{namespace}/servers/shutdown") .WithPathParam("namespace", this.namespace_) .WithBearerAuth(accessToken) .WithContentType(MediaType.ApplicationJson) .Accepts(MediaType.ApplicationJson) .WithBody(shutdownServerRequest.ToUtf8Json()) .GetResult(); IHttpResponse response = null; yield return(this.httpWorker.SendRequest(request, rsp => response = rsp)); var result = response.TryParse(); callback.Try(result); }
/// <summary> /// Register server ready to DSM /// </summary> /// <param name="killMe">Signaling DSM to forcefully shutdown this machine</param> /// <param name="callback">Returns a Result via callback when completed</param> public void ShutdownServer(bool killMe, ResultCallback callback) { Report.GetFunctionLog(this.GetType().Name); if (this.heartBeatCoroutine != null) { this.coroutineRunner.Stop(this.heartBeatCoroutine); this.heartBeatCoroutine = null; } if (!this.serverSession.IsValid()) { callback.TryError(ErrorCode.IsNotLoggedIn); return; } var request = new ShutdownServerRequest { kill_me = killMe, pod_name = this.name, session_id = this.matchSessionId }; this.coroutineRunner.Run(this.api.ShutdownServer(request, this.serverSession.AuthorizationToken, callback)); }