From a9ad0fde9e49166d9f8db0c622dc4d5af9316998 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Thu, 19 Jan 2023 14:27:33 +0900 Subject: [PATCH] After a plugin install or uninstall, restart now just kill the process instead of requiring SSH with docker install --- BTCPayServer/Controllers/UIServerController.cs | 13 +++++++++++-- BTCPayServer/Views/UIServer/ListPlugins.cshtml | 2 +- Changelog.md | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/BTCPayServer/Controllers/UIServerController.cs b/BTCPayServer/Controllers/UIServerController.cs index df377044d..3d1db70aa 100644 --- a/BTCPayServer/Controllers/UIServerController.cs +++ b/BTCPayServer/Controllers/UIServerController.cs @@ -33,6 +33,7 @@ using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Routing; +using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using MimeKit; @@ -87,7 +88,8 @@ namespace BTCPayServer.Controllers IOptions externalServiceOptions, Logs logs, LinkGenerator linkGenerator, - EmailSenderFactory emailSenderFactory + EmailSenderFactory emailSenderFactory, + IHostApplicationLifetime applicationLifetime ) { _policiesSettings = policiesSettings; @@ -110,6 +112,7 @@ namespace BTCPayServer.Controllers Logs = logs; _linkGenerator = linkGenerator; _emailSenderFactory = emailSenderFactory; + ApplicationLifetime = applicationLifetime; } [Route("server/maintenance")] @@ -131,7 +134,7 @@ namespace BTCPayServer.Controllers { vm.CanUseSSH = _sshState.CanUseSSH; - if (!vm.CanUseSSH) + if (command != "soft-restart" && !vm.CanUseSSH) { TempData[WellKnownTempData.ErrorMessage] = "Maintenance feature requires access to SSH properly configured in BTCPay Server configuration."; return View(vm); @@ -220,6 +223,11 @@ namespace BTCPayServer.Controllers return error; TempData[WellKnownTempData.SuccessMessage] = $"BTCPay will restart momentarily."; } + else if (command == "soft-restart") + { + TempData[WellKnownTempData.SuccessMessage] = $"BTCPay will restart momentarily."; + ApplicationLifetime.StopApplication(); + } else { return NotFound(); @@ -286,6 +294,7 @@ namespace BTCPayServer.Controllers } public IHttpClientFactory HttpClientFactory { get; } + public IHostApplicationLifetime ApplicationLifetime { get; } [Route("server/policies")] public async Task Policies() diff --git a/BTCPayServer/Views/UIServer/ListPlugins.cshtml b/BTCPayServer/Views/UIServer/ListPlugins.cshtml index 8c70f8809..a633f3689 100644 --- a/BTCPayServer/Views/UIServer/ListPlugins.cshtml +++ b/BTCPayServer/Views/UIServer/ListPlugins.cshtml @@ -127,7 +127,7 @@ @if (Model.CanShowRestart) {
- +
} diff --git a/Changelog.md b/Changelog.md index 7710597be..da9718cd2 100644 --- a/Changelog.md +++ b/Changelog.md @@ -12,6 +12,7 @@ ### Improvement +* After a plugin install or uninstall, restart now just kill the process instead of requiring SSH with docker install @NicolasDorier * Checkout v2: Display and copy addresses (#4489) @dennisreimann * Checkout v2: Configure countdown timer (#4471) @dennisreimann * Unify 2FA login boxes (#4506) @dennisreimann