static void Main() { var starter = new HostStarter("RS", new RsHostFactory()); starter.SetParametersFromCommandLine(Environment.CommandLine); starter.Description = Properties.Resources.AppDescription; starter.Start(); }
static void Main(string[] args) { var starter = new HostStarter("SI", new IntegrationServiceHostFactory()); starter.SetParametersFromCommandLine(Environment.CommandLine); starter.Description = Properties.Resources.AppDescription; starter.Start(); }
public void Configuration(IAppBuilder app) { // register assemblies AutofacAssemblyStore.LoadAssembly("Brandscreen.Framework"); AutofacAssemblyStore.LoadAssembly("Brandscreen.Core"); AutofacAssemblyStore.LoadAssembly(Assembly.GetExecutingAssembly()); // create and activate host _host = HostStarter.CreateHost(); _host.Activate(); // Note: HostEventsHandler will be called // ensure http configuration InitializeHttp(_host); // setting logger factory so it can do logging via NLog app.SetLoggerFactory(_host.LifetimeScope.Resolve <ILoggerFactory>()); // handling begin and end request events app.Use(async(context, next) => { _host.BeginRequest(); // begin request try { await next(); } catch (OperationCanceledException ex) { var logger = app.CreateLogger(GetType()); logger.WriteWarning(ex.Message); } catch (Exception ex) { var logger = app.CreateLogger(GetType()); logger.WriteError("owin error", ex); throw; } finally { _host.EndRequest(); // end request } }); // handling application end event var properties = new AppProperties(app.Properties); properties.OnAppDisposing.Register(() => _host.Terminate()); // end app // setup autofac middleware app.UseAutofacMiddleware(_host.LifetimeScope); // IOwinContext is registered by autofac when calling this // setup ConfigureMvc(app, _host); ConfigureApi(app, _host); }
static void Main(string[] args) { try { var settingsResolver = ApplicationSettingsResolver.GetSettingsResolver(); var baseUrl = settingsResolver("APIServiceUrl"); using (var serviceHost = new HostStarter(settingsResolver, baseUrl, args)) { Console.WriteLine($"Service is ready on {baseUrl}{Environment.NewLine}Press Ctrl-C to exit"); AttachExitHandlers(); exitEvent.WaitOne(); Environment.Exit(0); } } catch (Exception ex) { Console.WriteLine($"Fatal error in starting {serviceTypeName} service. Exception {ex}"); throw; } }
public void SetUp() { // init container host for testing, web api will use different one AutofacAssemblyStore.LoadAssembly("Brandscreen.Framework"); AutofacAssemblyStore.LoadAssembly("Brandscreen.Core"); AutofacAssemblyStore.LoadAssembly("Brandscreen.WebApi"); Host = HostStarter.CreateHost(); AutofacAssemblyStore.ClearAssemblies(); // clear loaded assemblies so that it won't affect web api Startup // passes the test scope to web app, so it will use to activate RepositoryTestModule // the scope will be set again on the starting of each test case in IocSupportedTests // the scope is used for resolving same instance of objects as the ones in current running test case for each http request made through the test case // e.g. the database context must be the same both in the current running test case and web api current request context, // then it is able to rollback all temporary data within the test scope. Startup.SetCurrentTestScope(Host.LifetimeScope); // init web app var ipAddress = LocalIpAddress(); Url = $"http://{ipAddress?.ToString() ?? "localhost"}:{Port}/"; Console.WriteLine("starting web app at {0}.", Url); _webApp = WebApp.Start <Startup>(Url); Console.WriteLine("started web app."); }
public static void Main(string[] args) { HostStarter.StartHost(args, ConfigureService); }
public void ConfigureContainer(ContainerBuilder builder) { HostStarter.InitializeHost(builder); }
public Startup(IConfiguration configuration) { Configuration = configuration; HostStarter.InitializeConfigurations(configuration); }