/// <summary> /// This is the entry point of the service host process. /// </summary> private static void Main() { try { // The ServiceManifest.XML file defines one or more service type names. // Registering a service maps a service type name to a .NET type. // When Service Fabric creates an instance of this service type, // an instance of the class is created in this host process. ServiceRuntime.RegisterServiceAsync("BinLogicServiceType", context => new BinLogicService(context)).GetAwaiter().GetResult(); ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(BinLogicService).Name); // Prevents this host process from terminating so services keep running. Thread.Sleep(Timeout.Infinite); } catch (Exception e) { ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString()); throw; } }
/// <summary> /// これは、サービス ホスト プロセスのエントリ ポイントです。 /// </summary> private static void Main() { try { // ServiceManifest.XML ファイルは、1 つ以上のサービス型の名前を定義します。 // サービスを登録すると、サービス型の名前が .NET 型にマップされます。 // Service Fabric がこのサービス型のインスタンスを作成すると、 // このホスト プロセスでクラスのインスタンスが作成されます。 ServiceRuntime.RegisterServiceAsync("AIQuestWebType", context => new AIQuestWeb(context)).GetAwaiter().GetResult(); ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(AIQuestWeb).Name); // サービスが実行を続けるために、このホスト プロセスが終了しないようにします。 Thread.Sleep(Timeout.Infinite); } catch (Exception e) { ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString()); throw; } }
/// <summary> /// 这是服务主机进程的入口点。 /// </summary> private static void Main() { try { // ServiceManifest.XML 文件定义一个或多个服务类型名称。 // 注册服务会将服务类型名称映射到 .NET 类型。 // 在 Service Fabric 创建此服务类型的实例时, // 会在此主机进程中创建类的实例。 ServiceRuntime.RegisterServiceAsync("WebApiType", context => new WebApi(context)).GetAwaiter().GetResult(); ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(WebApi).Name); // 防止此主机进程终止,以使服务保持运行。 Thread.Sleep(Timeout.Infinite); } catch (Exception e) { ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString()); throw; } }
/// <summary> /// This is the entry point of the service host process. /// </summary> private static void Main() { try { // The ServiceManifest.XML file defines one or more service type names. // Registering a service maps a service type name to a .NET type. // When Service Fabric creates an instance of this service type, // an instance of the class is created in this host process. ServiceRuntime.RegisterServiceAsync("AuditlogServiceType", context => new AuditlogService(context)).GetAwaiter().GetResult(); ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(AuditlogService).Name); // get configuration var rabbitMQConfigSection = Config.GetSection("RabbitMQ"); string host = rabbitMQConfigSection["Host"]; string userName = rabbitMQConfigSection["UserName"]; string password = rabbitMQConfigSection["Password"]; var auditlogConfigSection = Config.GetSection("Auditlog"); string logPath = auditlogConfigSection["path"]; // start auditlog manager RabbitMQMessageHandler messageHandler = new RabbitMQMessageHandler(host, userName, password, "Pitstop", "Auditlog", ""); AuditLogManager manager = new AuditLogManager(messageHandler, logPath); manager.Start(); // Prevents this host process from terminating so services keep running. Thread.Sleep(Timeout.Infinite); } catch (Exception e) { ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString()); throw; } }
public static void Main(string[] args) { // Create Service Fabric runtime and register the service type. try { //Creating a new event listener to redirect the traces to a file ServiceEventListener listener = new ServiceEventListener("CounterActorWebService"); listener.EnableEvents(ServiceEventSource.Current, EventLevel.LogAlways, EventKeywords.All); // The ServiceManifest.XML file defines one or more service type names. // Registering a service maps a service type name to a .NET type. // When Service Fabric creates an instance of this service type, // an instance of the class is created in this host process. ServiceRuntime.RegisterServiceAsync("CounterActorWebServiceType", context => new CounterActorWebService(context)).GetAwaiter().GetResult(); // Prevents this host process from terminating so services keep running. Thread.Sleep(Timeout.Infinite); } catch (Exception ex) { ServiceEventSource.Current.ServiceHostInitializationFailed(ex); throw ex; } }
/// <summary> /// This is the entry point of the service host process. /// </summary> private static void Main() { try { using (var pipeline = ServiceFabricDiagnosticPipelineFactory.CreatePipeline("PartyCluster.ApplicationDeployService")) { ServiceRuntime.RegisterServiceAsync( "ApplicationDeployServiceType", context => new ApplicationDeployService(new ReliableStateManager(context), new FabricClientApplicationOperator(context), context) ) .GetAwaiter().GetResult(); ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(ApplicationDeployService).Name); Thread.Sleep(Timeout.Infinite); // Prevents this host process from terminating to keep the service host process running. } } catch (Exception e) { ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString()); throw; } }
/// <summary> /// Este é o ponto de entrada do processo de host de serviço. /// </summary> private static void Main() { try { // O arquivo ServiceManifest.XML define um ou mais nomes de tipo de serviço. // Registrar um serviço mapeia um nome de tipo de serviço para um tipo de .NET. // Quando o Service Fabric cria uma instância deste tipo de serviço, // uma instância da classe é criada neste processo de host. ServiceRuntime.RegisterServiceAsync("VotingStateType", context => new VotingState(context, new InitializationCallbackAdapter())).GetAwaiter().GetResult(); ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(VotingState).Name); // Impede que este processo de host seja encerrado para que os serviços continuem em execução. Thread.Sleep(Timeout.Infinite); } catch (Exception e) { ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString()); throw; } }
/// <summary> /// This is the entry point of the service host process. /// </summary> private static void Main() { ILogger logger = null; try { // The ServiceManifest.XML file defines one or more service type names. // Registering a service maps a service type name to a .NET type. // When Service Fabric creates an instance of this service type, // an instance of the class is created in this host process. ServiceRuntime.RegisterServiceAsync("MyStatelessType", context => { var applicationInsightsKey = FabricRuntime.GetActivationContext() .GetConfigurationPackageObject("Config") .Settings .Sections["ConfigurationSection"] .Parameters["ApplicationInsightsKey"] .Value; var loggerFactory = new LoggerFactoryBuilder(context).CreateLoggerFactory(applicationInsightsKey); logger = loggerFactory.CreateLogger <MyStateless>(); return(new MyStateless(context, logger)); }).GetAwaiter().GetResult(); // Prevents this host process from terminating so services keep running. Thread.Sleep(Timeout.Infinite); } catch (Exception e) { logger?.LogStatelessServiceInitalizationFailed <MyStateless>(e); throw; } }
public static void Main(string[] args) { try { ServiceRuntime.RegisterServiceAsync( StringResource.ChaosTestServiceType, context => new ChaosService(context)).GetAwaiter().GetResult(); AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(LoadFromFabricCodePath); ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(ChaosService).Name); // "Restart code package" fault - generated by Chaos engine - uses Ctrl+C internally, // and visual studio debugger breaks on Thread.Sleep if Ctrl+C happens; // So, if debugger break on the line below, please just hit "Continue". Thread.Sleep(Timeout.Infinite); } catch (Exception e) { ServiceEventSource.Current.ServiceHostInitializationFailed(e); throw; } }
/// <summary> /// This is the entry point of the service host process. /// </summary> private static void Main() { if (!IsServiceFabricAvailable) { int iteration = 1; while (true) { string logMessage = $"Iteration: {iteration} [Debug Build: {IsDebugBuild}]"; Console.WriteLine(logMessage); Debug.WriteLine(logMessage); iteration++; Thread.Sleep(TimeSpan.FromSeconds(2)); } } try { // The ServiceManifest.XML file defines one or more service type names. // Registering a service maps a service type name to a .NET type. // When Service Fabric creates an instance of this service type, // an instance of the class is created in this host process. ServiceRuntime.RegisterServiceAsync("Web1Type", context => new Web1(context)).GetAwaiter().GetResult(); ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(Web1).Name); // Prevents this host process from terminating so services keeps running. Thread.Sleep(Timeout.Infinite); } catch (Exception e) { ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString()); throw; } }
public static void Main(string[] args) { try { using (TextWriterTraceListener trace = new TextWriterTraceListener(Path.Combine(FabricRuntime.GetActivationContext().LogDirectory, "out.log"))) { Trace.AutoFlush = true; Trace.Listeners.Add(trace); ServiceRuntime.RegisterServiceAsync( Service.ServiceTypeName, context => new Service(context)).GetAwaiter().GetResult(); ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, Service.ServiceTypeName); Thread.Sleep(Timeout.Infinite); } } catch (Exception e) { Trace.WriteLine(e); ServiceEventSource.Current.ServiceHostInitializationFailed(e); } }
/// <summary> /// This is the entry point of the service host process. /// </summary> private static async Task Main() { Logger.Initialize( EtwProviderNames.CloudBornApplicationOperation, ServiceFabricUtilities.AppBuildVersion, "CloudBornWorker"); using (var operation = Logger.StartOperation(OperationDataBuilder.Create(OperationCloudBornWorker.ProgramMain))) { await operation.RunAsync(async() => { // The ServiceManifest.XML file defines one or more service type names. // Registering a service maps a service type name to a .NET type. // When Service Fabric creates an instance of this service type, // an instance of the class is created in this host process. await ServiceRuntime.RegisterServiceAsync( "Service.CloudBornWorkerType", context => new CloudBornWorker(context)); }); } // Prevents this host process from terminating so services keep running. await Task.Delay(Timeout.Infinite); }
/// <summary> /// This is the entry point of the service host process. /// </summary> private static void Main() { try { // The ServiceManifest.XML file defines one or more service type names. // Registering a service maps a service type name to a .NET type. // When Service Fabric creates an instance of this service type, // an instance of the class is created in this host process. ServiceRuntime.RegisterServiceAsync("StatefulServiceType", context => { var testProvider = new TestOrchestrationsProvider(); var listener = new TaskHubProxyListener(context, testProvider.GetFabricOrchestrationProviderSettings(), testProvider.RegisterOrchestrations); return(new TaskHubStatefulService(context, new[] { listener })); }).GetAwaiter().GetResult(); // Prevents this host process from terminating so services keep running. Thread.Sleep(Timeout.Infinite); } catch (Exception e) { Trace.WriteLine(e); throw; } }
public static int Main(string[] args) { int status = 0; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; try { ServiceRuntime.RegisterServiceAsync( UpgradeOrchestrationServiceType, ReadConfiguration).GetAwaiter().GetResult(); Program.ServiceAgent = UpgradeOrchestrationServiceAgent.Instance; Thread.Sleep(Timeout.Infinite); } catch (Exception e) { UpgradeOrchestrationTrace.TraceSource.WriteError(TraceType, "Host failed: " + e.ToString()); throw; } return(status); }
public static void ServiceFabricHost() { ServiceRuntime.RegisterServiceAsync("InvSysCompaniesApiType", context => new WebHostingService(context, "ServiceEndpoint")).GetAwaiter().GetResult(); Thread.Sleep(Timeout.Infinite); }
/// <summary> /// This is the entry point of the service host process. /// </summary> private static void Main() { try { Log.Logger = new LoggerConfiguration() .MinimumLevel.Verbose() .WriteTo.Sink <EventSourceSink>() .CreateLogger(); var container = BuildRootContainer(); // The ServiceManifest.XML file defines one or more service type names. // Registering a service maps a service type name to a .NET type. // When Service Fabric creates an instance of this service type, // an instance of the class is created in this host process. ServiceRuntime.RegisterServiceAsync("ChannelDirectoryServiceType", context => { var scope = container.BeginLifetimeScope(builder => { builder.RegisterInstance(context) .AsSelf() .ExternallyOwned(); builder.Register(c => new ReliableStateManager(context, null)) .AsSelf() .As <IReliableStateManager>() .SingleInstance(); builder.RegisterType <ChannelDirectoryService>() .AsSelf() .SingleInstance(); builder.RegisterType <SubsystemManager>() .AsSelf() .SingleInstance(); builder.RegisterType <TwitchChannelManager>() .AsSelf() .SingleInstance(); builder.RegisterType <TwitchChannelRepository>() .As <ITwitchChannelRepository>() .As <ISubsystem>() .SingleInstance(); builder.RegisterType <TwitchChannelUpdaterSubsystem>().As <ISubsystem>().InstancePerDependency(); var serviceLogger = Log.Logger.ForContext(new ServiceContextLogEventEnricher(context)); builder.RegisterLogger(serviceLogger); }); return(scope.Resolve <ChannelDirectoryService>()); }).GetAwaiter().GetResult(); ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(ChannelDirectoryService).Name); // Prevents this host process from terminating so services keep running. Thread.Sleep(Timeout.Infinite); } catch (Exception e) { ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString()); throw; } }
public static void Register() { ServiceRuntime.RegisterServiceAsync(Naming.ServiceType <ValidationEngine>(), (context) => new ValidationEngine(context)); }
/// <summary> /// This is the entry point of the service host process. /// </summary> private static void Main() { try { // The ServiceManifest.XML file defines one or more service type names. // Registering a service maps a service type name to a .NET type. // When Service Fabric creates an instance of this service type, // an instance of the class is created in this host process. #region Startup Tasks // 1.) ------ System.Net.ServicePointManager.DefaultConnectionLimit = 12 * Environment.ProcessorCount; //<-- Allows us to marshal up more SearchService/SearchIndex Clients to avoid exhausting sockets. #region Working w/ Service Fabric Enviornment Variables //Pull in enviornment variables: ----------------------------------------------------------- //var hostId = Environment.GetEnvironmentVariable("Fabric_ApplicationHostId"); //var appHostType = Environment.GetEnvironmentVariable("Fabric_ApplicationHostType"); //var tyoeEndpoint = Environment.GetEnvironmentVariable("Fabric_Endpoint_[YourServiceName]TypeEndpoint"); //var nodeName = Environment.GetEnvironmentVariable("Fabric_NodeName"); //Or print them all out (Fabric Only): /* * foreach (DictionaryEntry de in Environment.GetEnvironmentVariables()) * { * if (de.Key.ToString().StartsWith("Fabric")) * { * ServiceEventSource.Current.ServiceMessage(this.Context, " Environment variable {0} = {1}", de.Key, de.Value); * } * } */ //EVERY SINGLE ONE: /* * foreach (DictionaryEntry de in Environment.GetEnvironmentVariables()) * { * ServiceEventSource.Current.ServiceMessage(this.Context, " Environment variable {0} = {1}", de.Key, de.Value); * * }*/ #endregion // 2.) ------ var nodeName = Environment.GetEnvironmentVariable("Fabric_NodeName"); // 3.) ------ // string environment = "production"; //RoleEnvironment.GetConfigurationSettingValue("Environment"); string environment = Environment.GetEnvironmentVariable("Env").ToLower(); Sahara.Core.Settings.Startup.Initialize(environment); Sahara.Core.Settings.Azure.CurrentRoleInstance.Name = nodeName; // RoleEnvironment.CurrentRoleInstance.Role.Name; //Sahara.Core.Settings.Azure.CurrentRoleInstance.Id = nodeName; //instanceIndex; // TODO: Track down use of Sahara.Core.Settings.Azure.CurrentRoleInstance.Id and replace with nodeName or anotehr var type //Trace.TraceInformation("Sahara.CoreServices.WcfEndpoints node:" + nodeName + " entry point called on env: " + environment); //Log Activity: PlatformLogManager.LogActivity( CategoryType.Worker, ActivityType.Worker_Status_Update, "Platform Worker starting on node '" + nodeName + "' (env: " + environment + ")....", "WORKER.PlatformWorker entry point called on env: " + environment + " (node:" + nodeName + ") (env: " + environment + ")" ); #endregion ServiceRuntime.RegisterServiceAsync("PlatformWorkerType", context => new PlatformWorker(context)).GetAwaiter().GetResult(); ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(PlatformWorker).Name); // Prevents this host process from terminating so services keep running. Thread.Sleep(Timeout.Infinite); } catch (Exception e) { ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString()); throw; } }
public static Task Main(string[] args) { ServiceRuntime.RegisterServiceAsync("Alethic.KeyShift.ServiceFabric.Sample.Service", ctx => new SampleService(ctx)); return(Task.Delay(Timeout.Infinite)); }
private void RegisterStatefulService <TService>( string serviceTypeName, Func <StatefulServiceContext, TService> ctor) where TService : StatefulService { _serviceCallbacks.Add(() => ServiceRuntime.RegisterServiceAsync(serviceTypeName, ctor)); }
public static void Register() { ServiceRuntime.RegisterServiceAsync(Naming.ServiceType <RestaurantAccess>(), (context) => new RestaurantAccess(context)); }
public static void Register() { ServiceRuntime.RegisterServiceAsync(Naming.ServiceType <SalesManager>(), (context) => new SalesManager(context)); }
public override Task RunServiceAsync(CancellationToken cancellationToken) => ServiceRuntime.RegisterServiceAsync(ApplicationName, ServiceFactory, cancellationToken: cancellationToken);
public static IUnityContainer WithStatefullService <TStatelessService>(this IUnityContainer container, string serviceTypeName, TimeSpan timeout = default(TimeSpan), CancellationToken cancellationToken = default(CancellationToken)) where TStatelessService : StatefulService { ServiceRuntime.RegisterServiceAsync(serviceTypeName, (context) => MakeServiceContainer(container, context).Resolve <TStatelessService>(), timeout, cancellationToken).GetAwaiter().GetResult(); return(container); }
/// <summary> /// This is the entry point of the service host process. /// </summary> private static void Main() { VegaDistributedTestService vegaDistributedTestService = null; try { var path = Assembly.GetExecutingAssembly().Location; var builder = new ConfigurationBuilder().SetBasePath(Path.GetDirectoryName(path)).AddJsonFile("appSettings.json"); appSettings = builder.Build(); var tenantName = GetClusterNameFromMsa().GetAwaiter().GetResult(); var nodeName = FabricRuntime.GetNodeContext().NodeName; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) { var errorContext = default(ErrorContext); var defaultDimensions = new Dictionary <string, string> { { "Tenant", tenantName }, { "Node", nodeName }, }; if (!DefaultConfiguration.SetDefaultDimensionNamesValues( ref errorContext, (uint)defaultDimensions.Count, defaultDimensions.Keys.ToArray(), defaultDimensions.Values.ToArray())) { VegaDistTestEventSource.Log.SetMdmDimensionFailed(errorContext.ErrorCode, errorContext.ErrorMessage); } } // Ensure the event source is loaded Assembly.GetAssembly(typeof(ITestJob)) .GetType("Microsoft.Vega.DistributedTest.VegaDistTestEventSource") ?.GetProperty("Log") ?.GetValue(null); LogFileEventTracing.Start(Path.Combine(appSettings["LogFolder"], "VegaDistributedTestService.LogPath")); Trace.Listeners.Add(new LogFileTraceListener()); LogFileEventTracing.AddEventSource("Microsoft-Azure-Networking-Infrastructure-RingMaster-DistributedTestService"); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; AppDomain.CurrentDomain.ProcessExit += (sender, eventArgs) => { LogFileEventTracing.Stop(); }; // The ServiceManifest.XML file defines one or more service type names. // Registering a service maps a service type name to a .NET type. // When Service Fabric creates an instance of this service type, // an instance of the class is created in this host process. ServiceRuntime.RegisterServiceAsync( "VegaDistTestSvc", context => vegaDistributedTestService = new VegaDistributedTestService(context)) .GetAwaiter() .GetResult(); VegaDistTestEventSource.Log.RegisterServiceSucceeded(); // Prevents this host process from terminating so services keep running. Thread.Sleep(Timeout.Infinite); } catch (Exception ex) { VegaDistTestEventSource.Log.RegisterServiceFailed(ex.ToString()); throw; } finally { if (vegaDistributedTestService != null) { vegaDistributedTestService.Dispose(); } } }
public static void Register() { ServiceRuntime.RegisterServiceAsync(Naming.ServiceType <PricingEngine>(), (context) => new PricingEngine(context)); }
// Entry point for the application. public static void Main(string[] args) { ServiceRuntime.RegisterServiceAsync("CoreMVCWebType", context => new WebHostingService(context, "ServiceEndpoint")).GetAwaiter().GetResult(); Thread.Sleep(Timeout.Infinite); }
private static void Main() { ServiceRuntime.RegisterServiceAsync("actors", ServiceFactory).GetAwaiter().GetResult(); Thread.Sleep(Timeout.Infinite); }
public static void Register() { ServiceRuntime.RegisterServiceAsync(Naming.ServiceType <CustomerAccess>(), (context) => new CustomerAccess(context)); }
// Entry point for the application. public static void Main(string[] args) { ServiceRuntime.RegisterServiceAsync("WorkServiceType", context => new WorkService(context)).GetAwaiter().GetResult(); Thread.Sleep(Timeout.Infinite); }