// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); var configTemplate = File.ReadAllText("./akka.conf"); var systemName = "akkaexample"; var akkaConfig = ConfigurationTemplating.WithEnvironmentVariables(configTemplate) .WithFallback(DistributedPubSub.DefaultConfig()) .WithFallback(ConfigurationFactory.Default()); services.AddSingleton(new WebService(systemName, akkaConfig)); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "Akka example", Version = "v1", }); // Configure Swagger to use the xml documentation file var xmlFile = Path.ChangeExtension(typeof(Startup).Assembly.Location, ".xml"); c.IncludeXmlComments(xmlFile); }); }
public static async Task Main(string[] args) { var configTemplate = File.ReadAllText("./akka.conf"); var systemName = "playground"; var akkaConfig = ConfigurationTemplating.WithEnvironmentVariables(configTemplate, ConfigurationFactory.Default()) .WithFallback(DistributedPubSub.DefaultConfig()) .WithFallback(ConfigurationFactory.Default()); var workerService = new WorkerService(systemName, akkaConfig); var tokenSource = new CancellationTokenSource(); AppDomain.CurrentDomain.ProcessExit += (_, __) => tokenSource.Cancel(); workerService.Start(tokenSource.Token); await workerService.TerminationHandle; }