zoukankan      html  css  js  c++  java
  • 回收应用程序池解决方法

       以下程序就是实现自动关闭并回收应用程序缓冲池。

    App.config内容

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <appSettings>
        <!-- 程序运行时隔(单位:毫秒) -->
        <add key ="TimeSpan" value ="10000"/>
        <!-- 要监视的进程(不加.exe),默认是vsjitdebugger -->
        <add key ="AppName" value ="zhaoPin.ClientServiceV2"/>
        <!-- 要回收的应用程序池名称 -->
        <add key ="Appool" value ="zhaoPin.Rc"/>
      </appSettings>
    </configuration>

    using System;
    using System.Diagnostics;
    using System.Configuration;
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                int i = 0;
                bool tag=false;
                Console.WriteLine("请不要关闭此窗口!!");
                string dd = System.Configuration.ConfigurationManager.AppSettings["TimeSpan"].ToString();
                string appname = System.Configuration.ConfigurationManager.AppSettings["AppName"].ToString();
                string appool = System.Configuration.ConfigurationManager.AppSettings["Appool"].ToString();
                while (true)
                {
                    System.Diagnostics.Process[] p = System.Diagnostics.Process.GetProcesses();
                    foreach (Process pi in p)
                        if (pi.ProcessName == appname)
                        {
                            tag=true;
                            pi.Kill();
                        }
                    if (tag)
                    {
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        i++;
                        string msg = RecycleAppol(appool);
                        Console.WriteLine("成功关闭" + i + "次!!");
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.WriteLine(msg);
                        tag = false;
                    }
                    System.Threading.Thread.Sleep(Convert.ToInt32(dd));
                }
            }
            static string RecycleAppol(string appoolname)
            {
                Process p = new Process();
                p.StartInfo.FileName = "cscript.exe";
                p.StartInfo.Arguments = "c:\windows\system32\iisapp.vbs /a "+appoolname+" /r";
                p.StartInfo.CreateNoWindow = false;
                p.StartInfo.UseShellExecute = false;
                p.StartInfo.RedirectStandardError = true;
                p.StartInfo.RedirectStandardInput = true;
                p.StartInfo.RedirectStandardOutput = true;
                p.Start();
                return p.StandardOutput.ReadToEnd();
            }

        }
    }

  • 相关阅读:
    centOS 开机自启动自己的脚本
    python SMTP 发送邮件 阿里企业邮箱、163邮箱 及535错误
    memcach 命令行
    python requests上传文件 tornado 接收文件
    Python memecache
    python Redis
    Slave_SQL_Running: No mysql同步故障解决方法
    mysql 数据库的主从同步
    Centos7 安装mysql5.7.16
    centos python2.6 升级到 python2.7
  • 原文地址:https://www.cnblogs.com/handafeng/p/IIS.html
Copyright © 2011-2022 走看看