Created
May 22, 2019 09:16
-
-
Save zyzsdy/f07d3ff332548039c20d3fe26cd88a60 to your computer and use it in GitHub Desktop.
Nginx windows版启动脚本,防止多开
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
if exist logs/nginx.pid ( goto checknginx ) else ( goto start ) | |
:checknginx | |
setlocal enabledelayedexpansion | |
for /f %%k in (logs/nginx.pid) do (set pid=%%k & goto next) | |
:next | |
wmic process get name,processid | findstr !pid! > ~pidprocess.txt | |
echo xxxxx >> ~pidprocess.txt | |
for /f %%i in (~pidprocess.txt) do (set processname=%%i & goto processcheck) | |
:processcheck | |
set processhead=!processname:~0,5! | |
if !processhead!==nginx ( echo Nginx already running ) else ( goto cleanandstart ) | |
goto end | |
:start | |
start nginx.exe | |
goto :eof | |
:cleanandstart | |
del ~pidprocess.txt | |
start nginx.exe | |
goto :eof | |
:end | |
rem clean | |
del ~pidprocess.txt | |
pause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
nginx -s stop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment