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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
 ///-------------------------------------------------------------------------------------------------
 /// <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")
 {
 }
Esempio n. 5
0
 ///-------------------------------------------------------------------------------------------------
 /// <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;
 }
Esempio n. 6
0
 ///-------------------------------------------------------------------------------------------------
 /// <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)
 {
 }
Esempio n. 7
0
 ///-------------------------------------------------------------------------------------------------
 /// <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)
 {
 }
Esempio n. 8
0
 ///-------------------------------------------------------------------------------------------------
 /// <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)
 {
 }
Esempio n. 9
0
 ///-------------------------------------------------------------------------------------------------
 /// <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)
 {
 }