internal override void shutdown() { _report.addDebug("The orchestrator is getting ready to shut down!"); _serviceState.Status = ServiceStatus.STOPPED; // first shut down our listener try { Client c = new Client(); c.connect(_myIp.ToString(), _listeningPort); if (!c.sendStopServerRequest("Requesting the orchestrator service shut down for end of day clean up")) { throw new ApplicationException("The server responded negatively to the shutdown request!"); } _report.addDebug("The orchestrator server ackowledged the shutdown request!"); System.Threading.Thread.Sleep(5000); // give this 5 seconds to complete // make sure the server has shut down try { c.connect(_myIp.ToString(), _listeningPort); c.disconnect(); throw new ApplicationException("The server responded successfully to the shutdown request but we can still connect!"); } catch (Exception) { /* want an exception here!! */ } _report.addDebug("Successfully confirmed server shutdown!"); } catch (Exception exc) { _report.addError("The orchestrator service is not responding properly to a shutdown request. It will need to be manually stopped!", exc); _report.HasError = "T"; throw; } // then stop any running jobs if (_extractors != null && _extractors.Count() > 0) { IList <Extractor> activeExtractors = _extractors.GetExtractors(); _report.addDebug("Found " + activeExtractors.Count + " active extractors - attempting to shut them down..."); foreach (Extractor e in activeExtractors) { shutdownClient(e.HostName, e.ListeningPort, 3); try { // the stop extractor request should unlock the site but we'll do it here again to make sure _sqlDao.unlockSite(e.SiteCode, e.VistaFile); } catch (Exception exc) { _report.addError("Trying end of day clean up - unable to unlock an extractor!", exc); _report.HasError = "T"; } } } }