简体   繁体   English

检查运行 windows 服务器的 php-fpm

[英]check php-fpm running windows server

i was working at Linux with php-fpm我正在使用 php-fpm 在 Linux 工作

and moved to windows server并移至 windows 服务器

i was able to check url file php by ssh command我能够通过 ssh 命令检查 url 文件 php

/usr/bin/curl --head  

if not found head at url restart php-fpm automatically with corn 2m如果在 url 处找不到头,用玉米 2m 自动重启 php-fpm

since i moved to windows am not able to do same因为我搬到了 windows 我不能做同样的事情

i found solution我找到了解决方案

script will check if a service is running and if it is not running it will start it.脚本将检查服务是否正在运行,如果它没有运行,它将启动它。 Only change the variable ServiceName to the name of the service you would like to check, ie Windows Update is wuauserv.只需将变量 ServiceName 更改为您要检查的服务的名称,即 Windows 更新为 wuauserv。

PowerShell PowerShell

@ECHO OFF 
SET SvcName=ServiceName 

SC QUERYEX "%SvcName%" | FIND "STATE" | FIND /v "RUNNING" > NUL && ( 
    ECHO %SvcName% is not running  
    ECHO START %SvcName% 

    NET START "%SvcName%" > NUL || ( 
        ECHO "%SvcName%" wont start  
        EXIT /B 1 
    ) 
    ECHO "%SvcName%" is started 
    EXIT /B 0 
) || ( 
    ECHO "%SvcName%" is running 
    EXIT /B 0 
)

If you want to use it as a scheduled task, you can change the line SET SvcName=Servicename to SET SvcName=%~1, you then can start it as check-service.cmd "ServiceName".如果您想将其用作计划任务,您可以将 SET SvcName=Servicename 行更改为 SET SvcName=%~1,然后您可以将其作为 check-service.cmd "ServiceName" 启动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM