Merge remote-tracking branch 'origin/feature/fix-ctrl-c-stop' into feature/windows-service-improvements
This commit is contained in:
@@ -251,6 +251,7 @@ namespace Duplicati.Server
|
||||
ConfigureLogging(commandlineOptions);
|
||||
|
||||
var crashed = false;
|
||||
var terminated = false;
|
||||
try
|
||||
{
|
||||
DataConnection = GetDatabaseConnection(commandlineOptions);
|
||||
@@ -306,7 +307,23 @@ namespace Duplicati.Server
|
||||
Console.WriteLine(Strings.Program.ServerStartedSignin(url));
|
||||
}
|
||||
|
||||
DuplicatiWebserver.TerminationTask.ContinueWith((t) =>
|
||||
{
|
||||
if (t.Exception != null)
|
||||
System.Diagnostics.Trace.WriteLine("Webserver terminated with exception: " + t.Exception);
|
||||
|
||||
terminated = true;
|
||||
ApplicationExitEvent.Set();
|
||||
});
|
||||
ServerStartedEvent.Set();
|
||||
|
||||
Console.WriteLine($"Server is now running on port {DuplicatiWebserver.Port}");
|
||||
if (FIXMEGlobal.Origin == "Server" && DataConnection.ApplicationSettings.AutogeneratedPassphrase)
|
||||
{
|
||||
var signinToken = DuplicatiWebserver.Provider.GetRequiredService<IJWTTokenProvider>().CreateSigninToken("server-cli");
|
||||
Console.WriteLine($"Initial signin url: http://localhost:{DuplicatiWebserver.Port}/signin.html?token={signinToken}");
|
||||
}
|
||||
|
||||
ApplicationExitEvent.WaitOne();
|
||||
}
|
||||
catch (SingleInstance.MultipleInstanceException mex)
|
||||
@@ -355,7 +372,7 @@ namespace Duplicati.Server
|
||||
{
|
||||
// If the server is already crashed, that is the main error
|
||||
// If the server crashes during teardown, we log that as an error
|
||||
if (!crashed)
|
||||
if (!(crashed || terminated))
|
||||
{
|
||||
System.Diagnostics.Trace.WriteLine(Strings.Program.TearDownError(ex.ToString()));
|
||||
if (writeToConsole)
|
||||
|
||||
@@ -24,6 +24,8 @@ public partial class DuplicatiWebserver
|
||||
|
||||
public int Port { get; private set; }
|
||||
|
||||
public Task TerminationTask { get; private set; } = Task.CompletedTask;
|
||||
|
||||
/// <summary>
|
||||
/// The settings used for stating the server
|
||||
/// </summary>
|
||||
@@ -200,7 +202,7 @@ public partial class DuplicatiWebserver
|
||||
App.AddEndpoints()
|
||||
.UseNotifications("/notifications");
|
||||
|
||||
return App.RunAsync();
|
||||
return TerminationTask = App.RunAsync();
|
||||
}
|
||||
|
||||
public async Task Stop()
|
||||
|
||||
Reference in New Issue
Block a user