Ejemplo n.º 1
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");
            }
        }
Ejemplo n.º 2
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..");
        }
Ejemplo n.º 3
0
Archivo: App.cs Proyecto: 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();
            }
        }