//static void Main(string[] args) //{ // //GlobalConfiguration.Configuration.UseSqlServerStorage("Server=(localdb)\\mssqllocaldb; Database=AcornBox; Trusted_Connection = True; MultipleActiveResultSets = true"); // GlobalConfiguration.Configuration.UseSqlServerStorage("Server=acornbox.db; Database=AcornBox; User=sa; Password=Your_password123"); // GlobalConfiguration.Configuration.UseActivator(new MyJobActivator()); // using (var server = new BackgroundJobServer()) // { // Console.WriteLine("Hangfire Server started. Press any key to exit..."); // Console.ReadKey(); // } //} static async Task Main(string[] args) { Console.WriteLine("AcornBox.Worker - Main - Entered"); var hostBuilder = new Microsoft.Extensions.Hosting.HostBuilder(); hostBuilder.ConfigureHostConfiguration(configHost => { configHost.SetBasePath(Directory.GetCurrentDirectory()); configHost.AddJsonFile("appsettings.json", optional: true); configHost.AddEnvironmentVariables(); configHost.AddCommandLine(args); }); hostBuilder.ConfigureServices(configServices => { configServices.AddHostedService <TimedHostedService>(); }); //hostBuilder.ConfigureServices((hostBuilderContext, serviceCollection) => //{ // serviceCollection.AddHostedService<TimedHostedService>(); //}); await hostBuilder.RunConsoleAsync(); Console.WriteLine("AcornBox.Worker - Main - Leaving"); }
static async Task Main(string[] args) { //dotnet GPS.IdentityServer4GrpcServer.dll ASPNETCORE_ENVIRONMENT=Development //Environment.SetEnvironmentVariable() var builder = new Microsoft.Extensions.Hosting.HostBuilder() .UseEnvironment(args[0].Split('=')[1]) .ConfigureAppConfiguration((hostingContext, config) => { config.SetBasePath(AppDomain.CurrentDomain.BaseDirectory); config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) .AddJsonFile($"appsettings.{ hostingContext.HostingEnvironment}.json", optional: true, reloadOnChange: true); config.AddEnvironmentVariables(); }) .ConfigureLogging((context, logging) => { logging.SetMinimumLevel(LogLevel.Debug); logging.AddConsole(); }) .ConfigureServices((hostContext, services) => { services.AddSingleton <ILoggerFactory, LoggerFactory>(); services.AddSingleton(typeof(ILogger <>), typeof(Logger <>)); services.AddSingleton(hostContext.Configuration); services.Configure <JwtOptions>(hostContext.Configuration.GetSection("JwtOptions")); //services.AddDbContext<GPSIdentityServerDbContext>(); ServiceProvider build = services.BuildServiceProvider(); services.AddSingleton <IList <Grpc.Core.Server> >( new List <Grpc.Core.Server>() { new Grpc.Core.Server { Services = { IdentityServer4ServiceGrpc.BindService(new IdentityServer4ServiceImpl(build)), }, Ports = { new ServerPort("0.0.0.0", 15500, ServerCredentials.Insecure) } } }); services.AddSingleton <IHostedService, GrpcBackgroundService>(); }); await builder.RunConsoleAsync(); }