• php使用winsw 实现windows上守护进程(win10测试可以)


    github:

    仓库地址: https://github.com/kohsuke/winsw
    下载地址: https://github.com/kohsuke/wi...

    步骤:

    1先到 https://github.com/kohsuke/winsw/releases 下载对应文件,如果没有特殊要求只为实现守护进程只需要下载  sample-minimal.xml WinSW.NET2.exeWinSW.NET4.exe

    2.在桌面新建一个文件夹(在哪里新建都可以)叫做 phpserver(名字英文,与要命名的服务名称相同,不能与已有的服务名称冲突)

    服务名称=

    文件夹示例:(文件夹初始只有自己下载的exe与配置文件,需要更名为与要创建的服务名称相同的名字。其他文件是我运行之后生成的)

     3.修改配置文件

    <!--
        Copyright (c) 2016 Oleg Nenashev and other contributors
    
        Permission is hereby granted, free of charge, to any person obtaining a copy of this 
        software and associated documentation files (the "Software"), to deal in the Software without
        restriction, including without limitation the rights to use, copy, modify, merge, publish,
        distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
        Software is furnished to do so, subject to the following conditions:
    
        The above copyright notice and this permission notice shall be included in all copies or 
        substantial portions of the Software.
    
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 
        BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
        NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
        DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    -->
    
    <!--
     This is an example of a minimal Windows Service Wrapper configuration, which includes only mandatory options.
     
     This configuration file should be placed near the WinSW executable, the name should be the same.
     E.g. for myapp.exe the configuration file name should be myapp.xml
     
     You can find more information about the configuration options here: https://github.com/kohsuke/winsw/blob/master/doc/xmlConfigFile.md
     Full example: https://github.com/kohsuke/winsw/blob/master/examples/sample-allOptions.xml
    -->
    <service>
      
      <!--服务ID 要唯一-->
      <id>phpservice</id>
      <!-- 服务名字 -->
      <name>phpservice</name>
      <!--服务描述 -->
      <description>test php service  </description>
      
      <!-- 要运行的文件 -->
      <executable>D:PhpStudyphpphp-7.4.1-ntsphp.exe</executable>
      <!-- 要执行的命令 -->
      <arguments>D:PhpStudyWWWindex.php</arguments>
    </service>

    4.执行命令

    // 安装服务 
    phpservice.exe install
    // 启动服务
    phpservice.exe stop
    // 停止服务
    phpservice.exe start
    // 重启服务(修改配置文件后要重启生效)
    phpservice.exe restart
    // 删除服务
    phpservice.exe uninstall

    5.服务设置 (当服务崩溃的时候进行重启)

    查看服务已正常运行:

    设置服务中断后的操作:

    主要参考

    https://segmentfault.com/a/1190000019520072

  • 相关阅读:
    正则表达式语法学习
    微软开放WP开发者回复用户应用评论功能
    下载安全程序需谨慎 黑客盯上XP用户
    软件业进入由大变强关键期
    54%的恶意程序无法被检测出
    CSS:第1课
    Javascript疑问【长期更新】
    不同语言的注释【长期更新】
    定制博客CSS样式
    认识Html DOM
  • 原文地址:https://www.cnblogs.com/xiaqiuchu/p/12535141.html
Copyright © 2020-2023  润新知