modules/InstallationSDK.ChefClientInstaller/code/WindowsService.cs
/// <summary>
/// Start Chef Client windows service. 
/// </summary>
Start Chef Client windows service.
Start Chef Client windows service .
public void Start()
        {
            try
            {
                Trace.TraceInformation("{0} - Attempting to start {0}.", Name);
                using (var chefService = new ServiceController(Name))
                {
                    if (chefService != null && chefService.Status != ServiceControllerStatus.Running)
                    {
                        chefService.Start();
                        chefService.WaitForStatus(ServiceControllerStatus.Running, TimeToWait);
                        Trace.TraceInformation("{0} - {0} Started.", Name);
                    }
                    else
                    {
                        Trace.TraceInformation("{0} - {0} previously running.", Name);
                    }
                }
            }
            catch (System.ServiceProcess.TimeoutException)
            {
                Trace.TraceInformation("{0} - failed to start Chef Client within time range.", Name);
            }
            catch (InvalidOperationException e)
            {
                Trace.TraceInformation("{0} - Invalid Operation, is the role running with elevated privileges. Ex:{1}.", Name, e.ToString());
            }
        }
public void Start ( ) { try { Trace . TraceInformation ( " " , Name ) ; using ( var chefService = new ServiceController ( Name ) ) { if ( chefService != null && chefService . Status != ServiceControllerStatus . Running ) { chefService . Start ( ) ; chefService . WaitForStatus ( ServiceControllerStatus . Running , TimeToWait ) ; Trace . TraceInformation ( " " , Name ) ; } else { Trace . TraceInformation ( " " , Name ) ; } } } catch ( System . ServiceProcess . TimeoutException ) { Trace . TraceInformation ( " " , Name ) ; } catch ( InvalidOperationException e ) { Trace . TraceInformation ( " " , Name , e . ToString ( ) ) ; } }
Start Chef Client windows service.
Start Chef Client windows service .
// Start Chef Client - wait 30 seconds