zoukankan      html  css  js  c++  java
  • nginx加入Windows服务开机自启动

    目标:将nginx加入Windows服务,实现开机自启动

    需要用到工具winsw,到该目录下,下载最新版winsw

    http://repo.jenkins-ci.org/releases/com/sun/winsw/winsw/

    源码: https://github.com/winsw/winsw

    新建个nginx目录,将winsw-2.9.0-bin.exe拷贝到该目录下并重命名为nginx-service.exe

    该目录下新建nginx-service.xml(exe与xml文件名要一致)

    <!-- nginx-service.xml -->
    <service>
      <id>nginx</id>
      <name>nginx</name>
      <description>This service runs nginx system.</description>
      <executable>D:
    ginx
    ginx.exe</executable>
      <startarguments>
        -c
        D:
    ginxWebUI
    ginx.conf
        -p
        D:
    ginx
      </startarguments>
      
      <stopexecutable>D:
    ginx
    ginx.exe</stopexecutable>
      <stoparguments>
        -p
        D:
    ginx
        -s
        stop
      </stoparguments>
      
      <log mode="roll"></log>
    </service>

    在该目录下shift+右键,打开cmd,执行

    nginx-service.exe install  # 安装服务(默认开机自启)
    nginx-service.exe start    # 启动服务
    
    nginx-service.exe uninstall  # 卸载服务

    同样的,可以添加nginxWebUI对应的xml来安装服务

    <!-- nginx-webui-service.xml -->
    <service>
      <id>nginx-webui</id>
      <name>nginx-webui</name>
      <description>This service runs nginxWebUI system.</description>
      <!-- <env name="JENKINS_HOME" value="%BASE%"/>  -->
      <executable>java</executable>
      <arguments>-Xmx64m -jar D:
    ginxWebUI
    ginxWebUI.jar --server.port=8086 --project.home=D:
    ginxWebUI</arguments>
      <log mode="roll"></log>
    </service>

    常用排查命令

    netstat -aon | findstr 0:8086
    
    tasklist | findstr 进程号或进程名
    
    taskkill /f /im 进程号或进程名
  • 相关阅读:
    java基础 01
    c++11——模板的细节改进
    c++11——auto,decltype类型推导
    poj_1182 并查集
    poj_1988 并查集
    poj_1161 并查集
    poj_3067 树状数组
    poj_2182 线段树/树状数组
    poj_1190 树状数组
    动态规划
  • 原文地址:https://www.cnblogs.com/ycc1/p/14312475.html
Copyright © 2011-2022 走看看