protected override void OnAfterInstall(IDictionary savedState)
 {
     ServiceConfigurator.SetRecoveryOptions(this.serviceInstaller.ServiceName);
     using (ServiceController pc = new ServiceController(this.serviceInstaller.ServiceName))
     {
         pc.Start();
     }
 }
Exemple #2
0
 protected override void OnAfterInstall(System.Collections.IDictionary savedState)
 {
     ServiceConfigurator.SetRecoveryOptions(ServiceName());
     using (ServiceController pc = new ServiceController(ServiceName()))
     {
         pc.Start();
     }
 }
Exemple #3
0
        protected override void OnBeforeUninstall(IDictionary savedState)
        {
            ServiceConfigurator.SetRecoveryOptions(this.serviceInstaller.ServiceName, ServiceConfigurator.SC_ACTION_NONE);
            var request = WebRequest.Create(String.Format("http://localhost:{0}/evacuate", RepService.RepPort));

            request.Method = "POST";
            WebResponse response;

            try
            {
                response = request.GetResponse();
            }
            catch (WebException)
            {
                base.OnBeforeUninstall(savedState);
                return;
            }
            var statusCode = ((HttpWebResponse)response).StatusCode;

            if (statusCode != HttpStatusCode.Accepted)
            {
                throw new Exception("unexpected status code received while evacuating: " + statusCode);
            }
            var sw = new Stopwatch();

            sw.Start();
            while (true)
            {
                request = WebRequest.Create(String.Format("http://localhost:{0}/ping", RepService.RepPort));
                try
                {
                    request.GetResponse();
                }
                catch (WebException)
                {
                    break;
                }
                if (sw.ElapsedMilliseconds > 1 * 60 * 1000)
                {
                    break;
                }
            }
            base.OnBeforeUninstall(savedState);
        }