Skip to content

Commit

Permalink
[CastIt.Server] Removed server controller.
Browse files Browse the repository at this point in the history
The server will now be hosted inside a win service
  • Loading branch information
Wolfteam committed Jul 31, 2021
1 parent 5f526b7 commit 85bfa0b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 48 deletions.
1 change: 1 addition & 0 deletions CastIt.Server/CastIt.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<PackageReference Include="FluentMigrator.Runner" Version="3.2.16" />
<PackageReference Include="FreeSql.Provider.Sqlite" Version="2.5.100" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.6" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="5.0.1" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="4.1.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.1.4" />
<PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="6.1.4" />
Expand Down
36 changes: 0 additions & 36 deletions CastIt.Server/Controllers/ServerController.cs

This file was deleted.

3 changes: 0 additions & 3 deletions CastIt.Server/Interfaces/IServerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using CastIt.Infrastructure.Models;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace CastIt.Server.Interfaces
{
Expand Down Expand Up @@ -59,7 +58,5 @@ public string GetPlayUrl(string filePath,
string GetSubTitleUrl();

string GetOutputMimeType(string mrl);

Task StopAsync();
}
}
9 changes: 8 additions & 1 deletion CastIt.Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ public static void Main(string[] args)

logs.SetupLogging(AppFileUtils.GetServerLogsPath());

#if !DEBUG
if (startingPort <= 0)
{
startingPort = WebServerUtils.GetOpenPort();
}
#endif
Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
CreateHostBuilder(args, startingPort).Build().Run();
}
Expand All @@ -57,6 +63,7 @@ public static IHostBuilder CreateHostBuilder(string[] args, int port) =>
})
//This has to happen AFTER ConfigureWebHostDefaults in order to get the server ip address
//https://stackoverflow.com/questions/58457143/net-core-3-0-ihostedservice-access-web-server-url-scheme-host-port-etc
.ConfigureServices(services => services.AddHostedService<CastItHostedService>());
.ConfigureServices(services => services.AddHostedService<CastItHostedService>())
.UseWindowsService();
}
}
8 changes: 0 additions & 8 deletions CastIt.Server/Services/ServerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;

namespace CastIt.Server.Services
{
Expand Down Expand Up @@ -172,13 +171,6 @@ public string GetOutputMimeType(string mrl)
return "video/webm";
}

public async Task StopAsync()
{
_logger.LogInformation("Stopping the server...");
await _server.StopAsync(default);
_hostApplicationLifetime.StopApplication();
}

private string SetUrlParameters(string baseUrl, object dto)
{
return QueryHelpers.AddQueryString(baseUrl, dto.ToKeyValue());
Expand Down

0 comments on commit 85bfa0b

Please sign in to comment.