zoukankan      html  css  js  c++  java
  • 在windows 上自动重启 tomcat 的方法

    在windows 上自动重启 tomcat 的方法

    实现思路:

    Windows 上监控tomcat 进程并且自动重启的脚本

    一类是 定时重启 tomcat

    一类是 监控并重启

    写一个守护tomcat进程 的脚本,间隔指定时间去访问 某个URL,对比HTTP 状态码是否为 200,如果不是,则重启tomcat

    实现方法:

    下载一个 windows 对应版本的 curl.exe ,将文件放入  C:WindowsSystem32 目录下

    写一个 bat 脚本

    @echo off
    set num=0
    
    :loop
    set "httpcode="
    rem cd /d c:curl
    for /f "delims=" %%r in ('curl.exe -sL -w "%%{http_code}" "http://127.0.0.1:8680/bpmp" -o nul') do (
      set httpcode=%%r
    )
    echo %httpcode%
    
    ping -n 30 127.0.0.1 >nul
    
    if not "%httpcode%" == "200"  goto count
    echo tomcat is ok
    goto loop
    
    :count
    set /a num+=1
    echo %num%
    if "%num%"=="5" goto restart
    goto loop
    
    
    :restart
    net stop tomcat8
    ping -n 10 127.0.0.1>nul
    net start tomcat8
    set num=0
    goto loop
  • 相关阅读:
    epoll 实现回射服务器
    select函数的介绍和使用
    期末项目需求分析报告
    Spring AOP Capabilities and Goals
    Domain Logic approaches
    Lamda Expression
    CDI furture
    23种设计模式
    connector for python
    Spring reference
  • 原文地址:https://www.cnblogs.com/panie2015/p/8547491.html
Copyright © 2011-2022 走看看