Example #1
0
 private ServiceStartupState GetServiceStartupState(OSPlatformType osPlatform, string startupState, string serviceName)
 {
     if (osPlatform == OSPlatformType.Linux)
     {
         if (startupState.ToLower().Contains("active") ||
             startupState.ToLower().Contains("enabled"))
         {
             return(ServiceStartupState.Active);
         }
         else if (startupState.ToLower().Contains("disabled"))
         {
             return(ServiceStartupState.Disabled);
         }
         else if (startupState.ToLower().Contains("failed"))
         {
             return(ServiceStartupState.Failed);
         }
         else if (startupState.ToLower().Contains("activating"))
         {
             return(ServiceStartupState.Activating);
         }
         else
         {
             throw new SystemInformationException($"ServiceStartupState \"{startupState}\" not recognized in linux system for service \"{serviceName}\".");
         }
     }
     else
     {
         throw new PlatformNotSupportedException("Platform not supported to get service startup state");
     }
 }
Example #2
0
 private ServiceState GetServiceState(OSPlatformType osPlatformType, string state, string serviceName)
 {
     if (osPlatformType == OSPlatformType.Linux)
     {
         if (state.ToLower().Contains("running")) ///Service
         {
             return(ServiceState.Running);
         }
         else if (state.ToLower().Contains("exited")) ///Service
         {
             return(ServiceState.Stopped);
         }
         else if (state.ToLower().Contains("")) ///Service
         {
             return(ServiceState.Failed);
         }
         else
         {
             throw new SystemInformationException($"ServiceStartupState \"{state}\" not recognized in linux system for service \"{serviceName}\"");
         }
     }
     else
     {
         throw new PlatformNotSupportedException("Platform not supported to get service state");
     }
 }
Example #3
0
 public IServiceManager Create(OSPlatformType osPlatformType)
 {
     if (osPlatformType == OSPlatformType.Linux ||
         osPlatformType == OSPlatformType.Windows)
     {
         return(container.Resolve <IServiceManager>(osPlatformType.ToString()));
     }
     else
     {
         throw new PlatformNotSupportedException();
     }
 }