Ejemplo n.º 1
0
    protected override Task ExecuteAsync(CancellationToken stoppingToken)
    {
        rpc.Dispatcher.RegisterService <IShiftService>(shiftService, "shift.");
        rpc.Dispatcher.RegisterMethodAlias(historyService, "rpc.history.get_topic", nameof(historyService.GetTopicHistory));
        rpc.UpdateRegisteredMethods();

        var srv1 = shiftService.RunAsync(stoppingToken);
        var srv2 = rpc.RunAsync(stoppingToken);
        var srv3 = simulation.RunAsync(stoppingToken);

        return(Task.WhenAny(srv1, srv2, srv3).ContinueWith((t) =>
        {
            if (t.Result.IsFaulted)
            {
                logger.LogError("Execution Stoped: {time} {error}", DateTimeOffset.Now, t.Result.Exception);
                Environment.Exit(-1);
            }
            else
            {
                logger.LogWarning("Execution Stoped: {time}", DateTimeOffset.Now);
            }
        }));
    }