コード例 #1
0
    public void ProcessServiceRequest(ServiceAction action, IISAppPool pool, int timeout)
    {
        AppPoolConfig status  = null;
        bool          success = false;

        switch (action)
        {
        case ServiceAction.Create:
            String username = pool.UserName;
            if (!String.IsNullOrWhiteSpace(pool.Domain))
            {
                username = pool.Domain + @"\" + pool.UserName;
            }
            AppPoolUtil.Create(pool.Name, pool.Server, config.Timeout, pool.ManagedRuntimeVersion, (int)pool.IdentityType, username, pool.Password);
            break;

        case ServiceAction.Delete:
            AppPoolUtil.Delete(pool.Name, pool.Server, config.Timeout);
            break;

        case ServiceAction.Query:
            break;

        case ServiceAction.Start:
            success = AppPoolUtil.Start(pool.Name, pool.Server, config.Timeout);
            break;

        case ServiceAction.Stop:
            success = AppPoolUtil.Stop(pool.Name, pool.Server, config.Timeout, 3, 5000);
            break;

        case ServiceAction.Restart:
            success = AppPoolUtil.Recycle(pool.Name, pool.Server, config.Timeout);
            break;

        case ServiceAction.StartMode:
            break;
        }

        status = AppPoolUtil.QueryStatus(pool.Name, false, pool.Server);

        if (status != null)
        {
            OnLogMessage(action.ToString(), "Name : [" + status.AppPoolName + "] Status : [" + status.State + "]");
            results.Add(status);
        }
    }
コード例 #2
0
        public void Initialize(AppPoolConfig config, IFileSystem fileSystem)
        {
            Config = config;
            FileSystem = fileSystem;

            m_Packages.Clear();

            var packagesDir = fileSystem.DirectoryInfo.FromDirectoryName(Config.PackagesDirectory);
            foreach (var file in packagesDir.GetFiles($"*{FileExtension.AppPackage}", SearchOption.TopDirectoryOnly))
            {
                using (var fileStream = file.Open(FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    var package = new AppPackage();
                    package.Load(fileStream);

                    AddPackage(package);
                }
            }
        }
コード例 #3
0
        public void RecycleOrRestartAppPool(AppPoolConfig appPoolConfigConfig)
        {
            var appPool = ServerManagerHelper.Instance.GetApplicationPool(appPoolConfigConfig.Name);

            if (appPool == null)
            {
                return;
            }

            switch (appPool.GetState())
            {
            case ObjectState.Started:
                appPool.Recycle();
                Logger.Instance.LogWarning(WebStarterConstants.ServiceName, $"Application pool ({appPoolConfigConfig.Name}) was recycled.");
                break;

            case ObjectState.Stopped:
                Logger.Instance.LogWarning(WebStarterConstants.ServiceName, $"Application pool ({appPoolConfigConfig.Name}) was started.");
                appPool.Start();
                break;
            }
        }