예제 #1
0
        public override async Task Close()
        {
            Trace.TraceInformation("Yams is sending an exit message to the app");
            try
            {
                UnsubscribeFromExited();

                await _ipcConnection.SendMessage("[EXIT]").Timeout(_config.GracefulShutdownMessageTimeout);

                Trace.TraceInformation("Exit message sent!");

                await _ipcConnection.Disconnect();

                if (!await ProcessUtils.SpinWaitForExit(this, (int)_config.AppGracefulShutdownTimeout.TotalSeconds))
                {
                    throw new TimeoutException($"The app {this.ExePath} did not exit in time");
                }
                Trace.TraceInformation("App has exited gracefully!");
            }
            catch (TimeoutException e)
            {
                Trace.TraceError($"App {ExePath} did not respond to exit message, attempting to close the process..{e.Message}");
                await _process.Close();

                Trace.TraceInformation("App has been closed");
            }
        }
예제 #2
0
        public async Task SendHeartBeat()
        {
            if (_healthConnection == null)
            {
                Trace.TraceError(
                    "Health monitoring is not supported for this app. Check your AppConfig.json file");
                return;
            }
            Trace.TraceInformation("Sending heart beat message to Yams..");
            await _healthConnection.SendMessage("[HEALTH_OK]")
            .Timeout(_config.HeartBeatMessageTimeout, "Send heart beat message to Yams has timed out");

            Trace.TraceInformation("Heart beat message has been sent to Yams successfully!");
        }
예제 #3
0
        public async Task SendInitializationDoneMessage()
        {
            if (_initConnection == null)
            {
                Trace.TraceError(
                    "Initialization monitoring is not supported for this app. Check your AppConfig.json file");
                return;
            }
            Trace.TraceInformation("Sending Initialization message to Yams..");
            await _initConnection.SendMessage("[INITIALIZE_DONE]")
            .Timeout(_config.InitDoneMessageTimeout, "Sending initialization message to Yams has timed out");

            Trace.TraceInformation("Initialization message has been sent to Yams successfully!");
        }