@echo off
set apache_vc=electronic_apache
set database_vc=electronic_mysql
set workerman_vc=electronic_worker
set apache_port=80
set database_port=1177
::C:\electronic\
set project_root=%~dp0%
set apache_dir=%project_root%Apache2
set database_dir=%project_root%MariaDB
set php_dir=%project_root%PHP7
cls
:: 窗口名称
title itc 电子桌牌系统
:: 设置字体颜色
color 0A
:: 固定窗口大小
mode con cols=80 lines=35 >nul 2>nul
goto :cfg
::服务检测头说明
:cfg
cls
echo ----服务器程序检测 -----------
goto :check
::服务检测主体
:check
if not exist %apache_dir%\logs\*.pid ( echo apache-%apache_port% 未启动 ) else ( echo apache-%apache_port% 已启动 )
echo.
tasklist|findstr /i mysqld.exe >nul 2>nul && echo mysql-%database_port% 已启动 || echo mysql-%database_port% 未启动
echo.
netstat -ano | findstr "0.0.0.0:1236" >nul 2>nul && echo 通讯服务器-1236 已启动 || echo 通讯服务器-1236 未启动
echo.
netstat -ano | findstr "0.0.0.0:2340" >nul 2>nul && echo 通讯服务器-2340 已启动 || echo 通讯服务器-2340 未启动
goto :menu
::服务重启修复
:fix
cls
echo ----服务器程序修复 -----------
echo.
echo apache-%apache_port% 开启修复中
echo.
net stop %apache_vc% >nul 2>nul
taskkill /im httpd.exe /f >nul 2>nul
%apache_dir%\bin\httpd.exe -k install -n %apache_vc% >nul 2>nul
sc failure %apache_vc% reset= 60 actions= restart/60000 >nul 2>nul
net start %apache_vc% >nul 2>nul
echo mysql-%database_port% 开启修复中
echo.
net stop %database_vc% >nul 2>nul
taskkill /im mysqld.exe /f >nul 2>nul
%database_dir%\bin\mysqld.exe --install %database_vc% --defaults-file="%database_dir%\my.ini" >nul 2>nul
sc failure %database_vc% reset= 60 actions= restart/60000 >nul 2>nul
net start %database_vc% >nul 2>nul
echo 通讯服务器(1236和2340)开启修复中
echo.
taskkill /im php.exe /f >nul 2>nul
sc Create %workerman_vc% binpath= "cmd.exe /c start %project_root%ele_daemon.exe" displayname= "%workerman_vc%" start= auto >nul 2>nul
start %project_root%ele_daemon.exe
::睡眠n秒等待服务启动
ping -n 10 127.0.0.1>nul
goto :check
::修复通讯服务器
:fix_t
cls
echo ----通讯服务器程序修复 -----------
echo.
echo 通讯服务器(1236和2340)开启修复中
echo.
taskkill /im php.exe /f >nul 2>nul
sc Create %workerman_vc% binpath= "cmd.exe /c start %project_root%ele_daemon.exe" displayname= "%workerman_vc%" start= auto >nul 2>nul
start %project_root%ele_daemon.exe
::睡眠n秒等待服务启动
ping -n 10 127.0.0.1>nul
goto :check
::卸载服务
:deleteall
echo.
echo 卸载服务中..
taskkill /im php.exe /f >nul 2>nul
sc delete %workerman_vc%
taskkill /im httpd.exe /f >nul 2>nul
%apache_dir%\bin\httpd.exe -k uninstall -n %apache_vc%>nul 2>nul
del /f/s/q %apache_dir%\logs\*.pid >nul 2>nul
taskkill /im mysqld.exe /f >nul 2>nul
%database_dir%\bin\mysqld.exe --remove %database_vc%>nul 2>nul
echo.
echo 卸载服务完成!
exit;
:menu
echo.
echo.
echo ----重新检测(s),全部程序修复(x),单独修复通讯服务器(t),退出(q) --
echo --修复服务器请输入x,端口若被其他程序占用请先关闭其他程序 ------
echo.
set input=
set /p input=-^>
cls
if /i "%input%"=="s" call :cfg
if /i "%input%"=="x" call :fix
if /i "%input%"=="t" call :fix_t
if /i "%input%"=="deleteall" goto :deleteall
if /i "%input%"=="q" exit
bat服务注册启动删除
最新推荐文章于 2024-04-26 14:26:48 发布