由于前端项目比较大,启动前端项目比较耗时,有时候又需要频繁切换不同环境进行调试,所以就本地安装了一个nginx服务,通过nginx代理到对应的后台环境,但是时间久了,频繁重启nginx也是挺烦的,于是就写了一个脚本来简化操作步骤,不论是启动还是重启,运行一下这个脚本就可以了。
脚本
命名一个nginx.bat
的文件,放到nginx的安装目录中
@echo offset "nginxPath=.\nginx.exe"tasklist /FI "IMAGENAME eq nginx.exe" 2>NUL | find /I /N "nginx.exe">NULif "%ERRORLEVEL%"=="0" (echo Nginx is running. Restarting...%nginxPath% -s reload) else (echo Nginx is not running. Starting...start "" "%nginxPath%")echo Done.exit /b@echo off set "nginxPath=.\nginx.exe" tasklist /FI "IMAGENAME eq nginx.exe" 2>NUL | find /I /N "nginx.exe">NUL if "%ERRORLEVEL%"=="0" ( echo Nginx is running. Restarting... %nginxPath% -s reload ) else ( echo Nginx is not running. Starting... start "" "%nginxPath%" ) echo Done. exit /b@echo off set "nginxPath=.\nginx.exe" tasklist /FI "IMAGENAME eq nginx.exe" 2>NUL | find /I /N "nginx.exe">NUL if "%ERRORLEVEL%"=="0" ( echo Nginx is running. Restarting... %nginxPath% -s reload ) else ( echo Nginx is not running. Starting... start "" "%nginxPath%" ) echo Done. exit /b
为方便起见,可以将该bat文件创建一个快捷方式放到桌面
© 版权声明
文章版权归作者所有,未经允许请勿转载,侵权请联系 admin@trc20.tw 删除。
THE END