I am trying to transition my ServiceStack Self Hosted full framework application to a .Net Core self hosted one.
The full .Net framework one is using TopShelf as follow:
The selfhost project is an example of creating a .NET Core App with the minimum dependencies, you can use the AddJsonFile() extension method as shown in Configuration in ASP.NET Core docs to add support for appsettings.json.
Note all .NET Core Apps are self-hosting Core Apps, unless there’s a reason to want to use the selfhost template you’re likely better off using the web template which uses the default CreateDefaultBuilder() configuration, e.g:
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
}
Does this mean that the app we always be running? For instance, I want to use SS along with a daily background job that re-authenticates to the SalesForce Api ( I hate 24 hour bearer tokens) to retrieve a bearer token every 24 hours. This would be on Windows behind IIS.
Under IIS you can simply disable automatic pool recycling for the hosting AppPool by setting “Regular Time Interval (minutes)” to 0. Then your app will never recycle, the default value is 1740.