Created
May 27, 2019 03:08
-
-
Save wallaceturner/2cf4bfe0ca805a109a344f8a282ab45b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Reflection; | |
using System.ServiceProcess; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore; | |
using Microsoft.AspNetCore.Hosting; | |
using Microsoft.AspNetCore.Hosting.WindowsServices; | |
using Microsoft.Extensions.Configuration; | |
using Microsoft.Extensions.Logging; | |
namespace ravendemo | |
{ | |
public class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
var host = CreateWebHostBuilder(args).Build(); | |
var isService = args.Contains("--service"); | |
if (isService) | |
{ | |
var baseDirectory = new FileInfo(Assembly.GetEntryAssembly().Location).Directory.FullName; | |
Directory.SetCurrentDirectory(baseDirectory); | |
} | |
if (isService) | |
{ | |
ServiceBase.Run(new WebHostService(host)); | |
} | |
else | |
{ | |
host.Run(); | |
} | |
} | |
public static IWebHostBuilder CreateWebHostBuilder(string[] args) => | |
WebHost.CreateDefaultBuilder(args) | |
.UseStartup<Startup>(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment