コード例 #1
0
 public virtual void OnShutdownRequest(Message message)
 {
     // Before shutting down, call any event set by the
     // engine.
     ShutdownRequest?.Invoke(message);
     System.Environment.Exit(0);
 }
コード例 #2
0
        private void OnStopDaemon()
        {
            notification_area.Hide();

            ShutdownRequest request = new ShutdownRequest();

            try {
                request.Send();
            } catch (Beagle.ResponseMessageException) {
                // beagled is not running
                NotificationMessage m = new NotificationMessage();
                m.Icon    = Gtk.Stock.DialogError;
                m.Title   = Catalog.GetString("Stopping service failed");
                m.Message = Catalog.GetString("Service was not running!");
                notification_area.Display(m);

                // show the start daemon if the user wants to start the daemom
                pages.CurrentPage = pages.PageNum(startdaemon);
                return;
            } catch (Exception e) {
                Console.WriteLine("Stopping the Beagle daemon failed: {0}", e.Message);
            }

            // beagled was running and should be now stopped.
            // Show the start page. The start-daemon page feels as if the user-request failed.
            pages.CurrentPage = pages.PageNum(quicktips);
            this.statusbar.Pop(0);
            this.statusbar.Push(0, Catalog.GetString("Search service stopped"));
        }
コード例 #3
0
ファイル: OwnerCommands.cs プロジェクト: 001101/Discord-Bot
        public async Task BotShutdown(CommandContext ctx)
        {
            Console.WriteLine("shutdown request");
            await LogPrivate(ctx.Channel as DiscordDmChannel, "Shutdown Bot", "With this command the bot will be shut down", $"Shutting down {DiscordEmoji.FromGuildEmote(ctx.Client, 491234510659125271)}", DiscordColor.Orange);

            ShutdownRequest.Cancel();
        }
コード例 #4
0
    public static int Main(string[] args)
    {
        if (Array.IndexOf(args, "--help") > -1)
        {
            VersionFu.PrintHeader();
            return(0);
        }

        if (Array.IndexOf(args, "--version") > -1)
        {
            VersionFu.PrintVersion();
            return(0);
        }

        ShutdownRequest request = new ShutdownRequest();

        try {
            request.Send();
        } catch {
            Console.WriteLine("ERROR: The Beagle daemon does not appear to be running");
            return(1);
        }

        return(0);
    }
コード例 #5
0
        internal UpsparkleUpdater()
        {
            var dllpath = string.Empty;

            var resourceName = string.Empty;
            var assembly     = Assembly.GetExecutingAssembly();

            if (IntPtr.Size == 4)
            {
                // 32-bit
                resourceName = $"{typeof(IUpsparkleUpdater).Namespace}.x86.{libraryName}";
                dllpath      = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "x86");
            }
            else
            {
                // 64-bit
                resourceName = $"{typeof(IUpsparkleUpdater).Namespace}.x64.{libraryName}";
                dllpath      = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "x64");
            }

            Utilites.LoadUnmanagedLibrary(Path.Combine(dllpath, libraryName));

            //Utilites.LoadUnmanagedLibraryFromResource(assembly, resourceName, libraryName);

            SetErrorCallback(() => Error?.Invoke(this, new EventArgs()));
            SetCanShutdownCallback(() => CanShutdown?.Invoke(this, new EventArgs()));
            SetShutdownRequestCallback(() => ShutdownRequest?.Invoke(this, new EventArgs()));
            SetDidFindUpdateCallback(() => DidFindUpdate?.Invoke(this, new EventArgs()));
            SetDidNotFindUpdateCallback(() => DidNotFindUpdate?.Invoke(this, new EventArgs()));
            SetUpdateCancelledCallback(() => UpdateCancelled?.Invoke(this, new EventArgs()));
        }
コード例 #6
0
        /// <summary>
        /// Implements a shutdown request for a session.
        /// </summary>
        public async Task <ShutdownResponse> ShutdownSessionAsync(ShutdownRequest request, CancellationToken token)
        {
            var cacheContext = new Context(new Guid(request.Header.TraceId), _logger);
            await _sessionHandler.ReleaseSessionAsync(new OperationContext(cacheContext, token), request.Header.SessionId);

            return(new ShutdownResponse());
        }
コード例 #7
0
        protected override void BeginConversation()
        {
            ShutdownRequest request = new ShutdownRequest(ProcToEnd);

            SendMessage(new Envelope(Destination, request));
            WaitingForReply = false;
        }
コード例 #8
0
ファイル: ShellServer.cs プロジェクト: vxfield/jupyter-core
        private void EventLoop(NetMQSocket socket)
        {
            this.logger.LogDebug("Starting shell server event loop at {Address}.", socket);
            while (alive)
            {
                try
                {
                    // Start by pulling off the next <action>_request message
                    // from the client.
                    var nextMessage = socket.ReceiveMessage(context);
                    logger.LogDebug(
                        $"Received new message:\n" +
                        $"\t{JsonConvert.SerializeObject(nextMessage.Header)}\n" +
                        $"\t{JsonConvert.SerializeObject(nextMessage.ParentHeader)}\n" +
                        $"\t{JsonConvert.SerializeObject(nextMessage.Metadata)}\n" +
                        $"\t{JsonConvert.SerializeObject(nextMessage.Content)}"
                        );

                    // If this is our first message, we need to set the session
                    // id.
                    if (session == null)
                    {
                        session = nextMessage.Header.Session;
                    }

                    // Get a service that can handle the message type and
                    // dispatch.
                    switch (nextMessage.Header.MessageType)
                    {
                    case "kernel_info_request":
                        KernelInfoRequest?.Invoke(nextMessage);
                        break;

                    case "execute_request":
                        ExecuteRequest?.Invoke(nextMessage);
                        break;

                    case "shutdown_request":
                        ShutdownRequest?.Invoke(nextMessage);
                        break;
                    }
                }
                catch (ProtocolViolationException ex)
                {
                    logger.LogCritical(ex, $"Protocol violation when trying to receive next ZeroMQ message.");
                }
                catch (ThreadInterruptedException)
                {
                    if (alive)
                    {
                        continue;
                    }
                    else
                    {
                        return;
                    }
                }
            }
        }
コード例 #9
0
        public void Any(ShutdownRequest request)
        {
            Response.ContentType = "text/html";
            Response.Write("<html><body>Closing...</body></html>");
            Response.Close();

            Environment.Exit(0);
        }
コード例 #10
0
        public async Task BotShutdown(CommandContext ctx)
        {
            await ctx.Guild.GetChannel(hcBotLogChannelId).SendMessageAsync($"Shuting down {DiscordEmoji.FromGuildEmote(ctx.Client, botEmote)}");

            await ctx.Message.DeleteAsync();

            ShutdownRequest.Cancel();
        }
コード例 #11
0
        public void Any(ShutdownRequest request)
        {
            Response.ContentType = "text/html";
            Response.Write("<html><body>Closing...</body></html>");
            Response.Close();

            Environment.Exit(0);
        }
コード例 #12
0
ファイル: Kernel.cs プロジェクト: stayyule/icsharp.kernel
        public void shutdownRequest(KernelMessage msg, ShutdownRequest content)
        {
            logMessage("shutdown request");
            var reply = new ShutdownReply()
            {
                restart = true
            };

            sendMessage(shellSocket, msg, "shutdown_reply", reply);
            System.Environment.Exit(0);
        }
コード例 #13
0
ファイル: BeagrepDaemon.cs プロジェクト: zweib730/beagrep
                public static void ReplaceExisting ()
                {
                        Log.Always ("Attempting to replace another beagrepd.");

                        do {
                                ShutdownRequest request = new ShutdownRequest ();
                                Logger.Log.Info ("Sending Shutdown");
                                request.Send ();
                                // Give it a second to shut down the messaging server
                                Thread.Sleep (1000);
                        } while (! StartServer ());
                }
コード例 #14
0
ファイル: Controller.cs プロジェクト: tmauldin/mb-unit
        public void Shutdown()
        {
            CheckProfileHasMaster();
            CheckProfileHasVM();

            Log(string.Format("Shutting down VM '{0}'.", profile.VM));
            ShutdownRequest request = new ShutdownRequest()
            {
                Vm = profile.VM
            };

            GetMasterClient().Shutdown(request);
        }
コード例 #15
0
ファイル: BeagrepDaemon.cs プロジェクト: qyqx/beagrep
        public static void ReplaceExisting()
        {
            Log.Always("Attempting to replace another beagrepd.");

            do
            {
                ShutdownRequest request = new ShutdownRequest();
                Logger.Log.Info("Sending Shutdown");
                request.Send();
                // Give it a second to shut down the messaging server
                Thread.Sleep(1000);
            } while (!StartServer());
        }
コード例 #16
0
        public override Task <ShutdownResponse> Shutdown(ShutdownRequest request, ServerCallContext context)
        {
            var response = new ShutdownResponse()
            {
                ResponseBase = CreateResponseBase()
            };

            RunCommand(nameof(Shutdown), () =>
            {
                connectionsService.HandleRequest(request.RequestBase);
                systemService.Shutdown();
            }, request.RequestBase, response.ResponseBase);
            return(Task.FromResult(response));
        }
コード例 #17
0
        public ShellServer(
            ILogger <ShellServer> logger,
            IOptions <KernelContext> context,
            IServiceProvider provider,
            IShellRouter router
            )
        {
            this.logger   = logger;
            this.context  = context.Value;
            this.provider = provider;
            this.router   = router;

            router.RegisterHandler("kernel_info_request", async message => KernelInfoRequest?.Invoke(message));
            router.RegisterHandler("shutdown_request", async message => ShutdownRequest?.Invoke(message));
        }
コード例 #18
0
        /// <summary>
        /// Shutdown TODO: Add Description
        /// </summary>
        /// <param name="contentType"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        public void ApplianceTechpreviewShutdownPoweroffPost(string contentType, ShutdownRequest body)
        {
            // verify the required parameter 'contentType' is set
            if (contentType == null)
            {
                throw new ApiException(400, "Missing required parameter 'contentType' when calling ApplianceTechpreviewShutdownPoweroffPost");
            }

            // verify the required parameter 'body' is set
            if (body == null)
            {
                throw new ApiException(400, "Missing required parameter 'body' when calling ApplianceTechpreviewShutdownPoweroffPost");
            }

            string path = "/appliance/techpreview/shutdown/poweroff";

            path = path.Replace("{format}", "json");

            Dictionary <string, string>        queryParams  = new Dictionary <string, string>();
            Dictionary <string, string>        headerParams = new Dictionary <string, string>();
            Dictionary <string, string>        formParams   = new Dictionary <string, string>();
            Dictionary <string, FileParameter> fileParams   = new Dictionary <string, FileParameter>();
            string postBody = null;

            if (contentType != null)
            {
                headerParams.Add("Content-Type", ApiClient.ParameterToString(contentType)); // header parameter
            }

            postBody = ApiClient.Serialize(body); // http body (model) parameter

            // authentication setting, if any
            string[] authSettings = new string[] { "auth" };

            // make the HTTP request
            IRestResponse response = (IRestResponse)ApiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);

            if (((int)response.StatusCode) >= 400)
            {
                throw new ApiException((int)response.StatusCode, "Error calling ApplianceTechpreviewShutdownPoweroffPost: " + response.Content, response.Content);
            }
            else if (response.StatusCode == 0)
            {
                throw new ApiException((int)response.StatusCode, "Error calling ApplianceTechpreviewShutdownPoweroffPost: " + response.ErrorMessage, response.ErrorMessage);
            }

            return;
        }
コード例 #19
0
ファイル: App.cs プロジェクト: punker76/XAMLTest
        public virtual async ValueTask DisposeAsync()
        {
            var request = new ShutdownRequest
            {
                ExitCode = 0
            };

            LogMessage?.Invoke($"{nameof(IApp)}.{nameof(DisposeAsync)}()");
            if (await Client.ShutdownAsync(request) is { } reply)
            {
                if (reply.ErrorMessages.Any())
                {
                    throw new Exception(string.Join(Environment.NewLine, reply.ErrorMessages));
                }
                return;
            }
            throw new Exception("Failed to get a reply");
        }
コード例 #20
0
        public ShutdownResponse Shutdown(ShutdownRequest request)
        {
            log.InfoFormat("Shutdown:\n  VM: {0}", request.Vm);

            string output;
            int    exitCode = ExecuteVBoxCommand("VBoxManage.exe",
                                                 string.Format("controlvm \"{0}\" acpipowerbutton", request.Vm),
                                                 TimeSpan.FromSeconds(30),
                                                 out output);

            if (exitCode != 0)
            {
                throw OperationFailed(
                          "Failed to shutdown the virtual machine.",
                          ErrorDetails(exitCode, output));
            }

            return(new ShutdownResponse());
        }
コード例 #21
0
        public async Task <ActionResult> CreateAdmin(ShutdownRequestModel model)
        {
            if (_workContext.CurrentUser == null)
            {
                return(AccessDeniedView());
            }

            DateTime baseDate;
            var      userCreate = await _userService.GetUserByIdAsync(model.UserCreatedId);

            if (model.BasePlanDate.Length > 10)
            {
                baseDate = DateTime.ParseExact(model.BasePlanDate.Substring(0, 24),
                                               "ddd MMM d yyyy HH:mm:ss",
                                               CultureInfo.InvariantCulture);
            }
            else
            {
                baseDate = Convert.ToDateTime(model.BasePlanDate);
            }
            if (userCreate != null)
            {
                var shutdownRequest = new ShutdownRequest
                {
                    Comment                = model.Comment,
                    CreatedDate            = DateTime.Now,
                    UpdatedDate            = DateTime.Now,
                    MakingScope            = model.MakingScope,
                    PackingScope           = model.PackingScope,
                    BasePlanDate           = baseDate,
                    ShutdownRequestContent = model.Content,
                    Remark         = model.Remark,
                    CreatedUser    = userCreate,
                    UserCreatedId  = userCreate.Id,
                    ShutdownStatus = (ShutdownStatus)model.StatusId
                };
                await _shutdownRequestService.InsertAsync(shutdownRequest);
            }
            return(new NullJsonResult());
        }
コード例 #22
0
ファイル: Shutdown.cs プロジェクト: ArsenShnurkov/beagle-1
	public static int Main (string[] args)
	{
		if (Array.IndexOf (args, "--help") > -1) {
			VersionFu.PrintHeader ();
			return 0;
		}

		if (Array.IndexOf (args, "--version") > -1) {
			VersionFu.PrintVersion ();
			return 0;
		}

		ShutdownRequest request = new ShutdownRequest ();

		try {
			request.Send ();
		} catch {
			Console.WriteLine ("ERROR: The Beagle daemon does not appear to be running");
			return 1;
		}

		return 0;
	}
コード例 #23
0
		private void OnStopDaemon ()
		{
			notification_area.Hide ();

			ShutdownRequest request = new ShutdownRequest ();
			try {
				request.Send ();
			} catch (Beagle.ResponseMessageException) {
				// beagled is not running
				NotificationMessage m = new NotificationMessage ();
				m.Icon = Gtk.Stock.DialogError;
				m.Title = Catalog.GetString ("Stopping service failed");
				m.Message = Catalog.GetString ("Service was not running!");
				notification_area.Display (m);

				// show the start daemon if the user wants to start the daemom
				pages.CurrentPage = pages.PageNum (startdaemon);
				return;
			} catch (Exception e) {
				Console.WriteLine ("Stopping the Beagle daemon failed: {0}", e.Message);
			}

			// beagled was running and should be now stopped.
			// Show the start page. The start-daemon page feels as if the user-request failed.
			pages.CurrentPage = pages.PageNum (quicktips);
			this.statusbar.Pop (0);
			this.statusbar.Push (0, Catalog.GetString ("Search service stopped"));
		}
コード例 #24
0
 /// <nodoc />
 protected abstract AsyncUnaryCall <ShutdownResponse> ShutdownSessionAsync(ShutdownRequest shutdownRequest);
コード例 #25
0
        public override CommandResult Execute()
        {
            var request = new ShutdownRequest(ServiceProvider);

            return(HandleRequest(null, request, caller: this));
        }
コード例 #26
0
 public ShutdownReply Shutdown(ShutdownRequest r)
 {
     ServerContext.RaiseShutdown();
     return(ShutdownReply.CreateSuccess());
 }
コード例 #27
0
        public ShutdownResponse Shutdown(ShutdownRequest request)
        {
            log.InfoFormat("Shutdown:\n  VM: {0}", request.Vm);

            string output;
            int exitCode = ExecuteVBoxCommand("VBoxManage.exe",
                string.Format("controlvm \"{0}\" acpipowerbutton", request.Vm),
                TimeSpan.FromSeconds(30),
                out output);

            if (exitCode != 0)
            {
                throw OperationFailed(
                    "Failed to shutdown the virtual machine.", 
                    ErrorDetails(exitCode, output));
            }

            return new ShutdownResponse();
        }
コード例 #28
0
ファイル: GrpcContentClient.cs プロジェクト: kittinap/kunnjae
 /// <inheritdoc />
 protected override AsyncUnaryCall <ShutdownResponse> ShutdownSessionAsync(ShutdownRequest shutdownRequest)
 {
     return(_client.ShutdownSessionAsync(shutdownRequest));
 }
コード例 #29
0
 /// <inheritdoc />
 public override Task <ShutdownResponse> ShutdownSession(ShutdownRequest request, ServerCallContext context) => _contentServer.ShutdownSessionAsync(request, context.CancellationToken);
コード例 #30
0
ファイル: Controller.cs プロジェクト: timonela/mb-unit
        public void Shutdown()
        {
            CheckProfileHasMaster();
            CheckProfileHasVM();

            Log(string.Format("Shutting down VM '{0}'.", profile.VM));
            ShutdownRequest request = new ShutdownRequest() { Vm = profile.VM };
            GetMasterClient().Shutdown(request);
        }