Exemplo n.º 1
0
        private static async Task Run(string[] args)
        {
            Console.WriteLine("args " + string.Join(" ", args));
            int shutdownDelay = 1000 * Convert.ToInt32(args[2]);

            var yamsClientConfig  = new YamsClientConfigBuilder(args).Build();
            var yamsClientFactory = new YamsClientFactory();

            Console.WriteLine("Initializing...");
            IYamsClient yamsClient = yamsClientFactory.CreateYamsClient(yamsClientConfig);

            await yamsClient.Connect();

            Console.WriteLine("Initialization done!");

            bool exitMessageReceived = false;

            yamsClient.ExitMessageReceived += (sender, eventArgs) =>
            {
                Console.WriteLine("Exit message received!");
                exitMessageReceived = true;
            };

            File.WriteAllText($"GracefulShutdownApp.exe.out", $"GracefulShutdownApp.exe {args[0]} {args[1]}");

            while (!exitMessageReceived)
            {
                await Task.Delay(100);

                Console.WriteLine("Doing work");
            }
            await Task.Delay(shutdownDelay);

            Console.WriteLine("Exiting..");
        }
Exemplo n.º 2
0
        private static async Task Run(string[] args)
        {
            Console.WriteLine("args " + string.Join(" ", args));
            var heartBeatPeriod = TimeSpan.FromSeconds(Convert.ToInt32(args[2]));

            var yamsClientConfig  = new YamsClientConfigBuilder(args).Build();
            var yamsClientFactory = new YamsClientFactory();

            Console.WriteLine("Initializing...");
            IYamsClient yamsClient = yamsClientFactory.CreateYamsClient(yamsClientConfig);

            await yamsClient.Connect();

            File.WriteAllText($"HeartBeatApp.exe.out", $"HeartBeatApp.exe {args[0]} {args[1]}");

            while (true)
            {
                await Task.Delay(heartBeatPeriod);

                Console.WriteLine("Sending heart beat..");
                await yamsClient.SendHeartBeat();

                Console.WriteLine("Heart beat sent!");
            }
        }
Exemplo n.º 3
0
        private static async Task Run(string[] args)
        {
            Console.WriteLine("args " + string.Join(" ", args));
            var yamsClientConfig  = new YamsClientConfigBuilder(args).Build();
            var yamsClientFactory = new YamsClientFactory();

            Console.WriteLine("Initializing...");
            IYamsClient yamsClient = yamsClientFactory.CreateYamsClient(yamsClientConfig);

            Task initTimeMax = Task.Delay(1000 * Convert.ToInt32(args[2]));

            File.WriteAllText($"MonitorInitApp.exe.out", $"MonitorInitApp.exe {args[0]} {args[1]}");

            await Task.WhenAll(yamsClient.Connect(), Task.Delay(TimeSpan.FromSeconds(5)), initTimeMax);

            Console.WriteLine("Send initialization done message...");
            await yamsClient.SendInitializationDoneMessage();

            Console.WriteLine("Initialization done message sent!");

            while (true)
            {
                await Task.Delay(1000);

                Console.WriteLine("Doing work");
            }
        }
Exemplo n.º 4
0
        private static async Task Run(string[] args)
        {
            Console.WriteLine("args " + string.Join(" ", args));
            var yamsClientConfig  = new YamsClientConfigBuilder(args).Build();
            var yamsClientFactory = new YamsClientFactory();

            IYamsClient yamsClient = yamsClientFactory.CreateYamsClient(yamsClientConfig);

            await Task.WhenAll(yamsClient.Connect(), Initialize());

            bool exitMessageReceived = false;

            yamsClient.ExitMessageReceived += (sender, eventArgs) =>
            {
                Console.WriteLine("Exit message received!");
                exitMessageReceived = true;
            };

            File.WriteAllText($"FullIpcApp.exe.out", $"FullIpcApp.exe {args[0]} {args[1]}");

            Console.WriteLine("Send initialization done message...");
            await yamsClient.SendInitializationDoneMessage();

            Console.WriteLine("Initialization done message sent!");

            while (!exitMessageReceived)
            {
                await DoWork();

                Console.WriteLine("Sending heart beat..");
                await yamsClient.SendHeartBeat();

                Console.WriteLine("Heart beat sent!");
            }
            await Shutdown();

            Console.WriteLine("Exiting..");
        }
Exemplo n.º 5
0
Arquivo: App.cs Projeto: zhonli/Yams
        private static async Task MainAsync(string[] args)
        {
            Id         = args[0];
            Version    = args[1];
            ClusterId  = args[2];
            InstanceId = args[3];

            Version version    = new Version(Version);
            string  apiVersion = $"{version}";
            string  baseUrl    = $"http://{GetIpAddress()}:8008/{Id}/{apiVersion}";

            Console.WriteLine("Url is: " + baseUrl);

            // Start OWIN host
            Microsoft.Owin.Hosting.WebApp.Start <Startup>(url: baseUrl);
            Console.WriteLine("WebApp has been started successfully");

            var         yamsClientConfig  = new YamsClientConfigBuilder(args).Build();
            var         yamsClientFactory = new YamsClientFactory();
            IYamsClient yamsClient        = yamsClientFactory.CreateYamsClient(yamsClientConfig);

            await yamsClient.Connect();

            await yamsClient.SendInitializationDoneMessage();

            var exitMessageReceived = false;

            yamsClient.ExitMessageReceived += (sender, eventArgs) => { exitMessageReceived = true; };

            while (!exitMessageReceived)
            {
                await Task.Delay(HeartBeatPeriod);

                await yamsClient.SendHeartBeat();
            }
        }