public static IWorkerHostBuilder UseAzureAppServiceShutdownHandler(this IWorkerHostBuilder hostBuilder) { // get the services var services = (hostBuilder as WorkerHostBuilder).Services; // add the worker (hostBuilder as WorkerHostBuilder).Services.AddSingleton <IShutdownNotificationService>(new AppServiceShutdownNotificationService()); // done return(hostBuilder); }
public static IWorkerHostBuilder UsePolling(this IWorkerHostBuilder hostBuilder, int pollingInterval) { // get the services var services = (hostBuilder as WorkerHostBuilder).Services; // add the worker (hostBuilder as WorkerHostBuilder).Services.AddSingleton( typeof(IWorkerHost), new WorkerHostPolling(services, pollingInterval)); // done return(hostBuilder); }
public static IWorkerHostBuilder UseStartup(this IWorkerHostBuilder hostBuilder, Type startupType) { var startupAssemblyName = startupType.GetTypeInfo().Assembly.GetName().Name; if (typeof(IStartup).GetTypeInfo().IsAssignableFrom(startupType.GetTypeInfo())) { hostBuilder.Services.AddSingleton(typeof(IStartup), startupType); } else { hostBuilder.Services.AddSingleton(typeof(IStartup), sp => { var hostingEnvironment = sp.GetRequiredService <IWorkerHostingEnvironment>(); return(new ConventionBasedStartup(StartupLoader.LoadMethods(sp, startupType, hostingEnvironment.EnvironmentName))); }); } return(hostBuilder); }
///------------------------------------------------------------------------------------------------- /// <summary> /// Initializes a new instance of the CreativeCoders.Daemon.Base.DaemonBase class. /// </summary> /// /// <param name="hostBuilder"> The host builder. </param> ///------------------------------------------------------------------------------------------------- protected DaemonBase(IWorkerHostBuilder hostBuilder) : this(hostBuilder, "--install", "--uninstall") { }
///------------------------------------------------------------------------------------------------- /// <summary> /// Initializes a new instance of the CreativeCoders.Daemon.Base.DaemonBase class. /// </summary> /// /// <param name="hostBuilder"> The host builder. </param> /// <param name="installArg"> The install argument. </param> /// <param name="uninstallArg"> The uninstall argument. </param> ///------------------------------------------------------------------------------------------------- protected DaemonBase(IWorkerHostBuilder hostBuilder, string installArg, string uninstallArg) { _hostBuilder = hostBuilder; _installArg = installArg; _uninstallArg = uninstallArg; }
///------------------------------------------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="WindowsServiceDaemon"/> class. /// </summary> /// /// <param name="hostBuilder"> The host builder. </param> ///------------------------------------------------------------------------------------------------- public WindowsServiceDaemon(IWorkerHostBuilder hostBuilder) : base(hostBuilder) { }
///------------------------------------------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="WindowsServiceDaemon"/> class. /// </summary> /// /// <param name="hostBuilder"> The host builder. </param> /// <param name="installArg"> The install argument. </param> /// <param name="uninstallArg"> The uninstall argument. </param> ///------------------------------------------------------------------------------------------------- public WindowsServiceDaemon(IWorkerHostBuilder hostBuilder, string installArg, string uninstallArg) : base(hostBuilder, installArg, uninstallArg) { }
///------------------------------------------------------------------------------------------------- /// <summary> Initializes a new instance of the <see cref="SystemdDaemon"/> class. </summary> /// /// <param name="hostBuilder"> The host builder. </param> ///------------------------------------------------------------------------------------------------- public SystemdDaemon(IWorkerHostBuilder hostBuilder) : base(hostBuilder) { }
///------------------------------------------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="SystemdDaemon"/> class. /// </summary> /// /// <param name="hostBuilder"> The host builder. </param> /// <param name="installArg"> The install argument. </param> /// <param name="uninstallArg"> The uninstall argument. </param> ///------------------------------------------------------------------------------------------------- public SystemdDaemon(IWorkerHostBuilder hostBuilder, string installArg, string uninstallArg) : base(hostBuilder, installArg, uninstallArg) { }