Add restart on config change if possible

This commit is contained in:
Jordan Brown
2018-09-08 14:43:49 -04:00
parent 425da91690
commit aac185e51b
@@ -10,6 +10,7 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Primitives;
using Microsoft.IdentityModel.Tokens;
using Newtonsoft.Json;
using System;
@@ -221,7 +222,8 @@ namespace Tgstation.Server.Host.Core
/// </summary>
/// <param name="applicationBuilder">The <see cref="IApplicationBuilder"/> to configure</param>
/// <param name="logger">The <see cref="ILogger"/> for the <see cref="Application"/></param>
public void Configure(IApplicationBuilder applicationBuilder, ILogger<Application> logger)
/// <param name="serverControl">The <see cref="IServerControl"/> for the application</param>
public void Configure(IApplicationBuilder applicationBuilder, ILogger<Application> logger, IServerControl serverControl)
{
if (applicationBuilder == null)
throw new ArgumentNullException(nameof(applicationBuilder));
@@ -229,6 +231,9 @@ namespace Tgstation.Server.Host.Core
throw new ArgumentNullException(nameof(logger));
logger.LogInformation(VersionString);
//attempt to restart the server if the configuration changes
ChangeToken.OnChange(configuration.GetReloadToken, () => serverControl.Restart());
applicationBuilder.UseDeveloperExceptionPage(); //it is not worth it to limit this, you should only ever get it if you're an authorized user