Nginx window环境下用winsw制作开机服务

来自ling
跳转至: 导航搜索

github winsw

可用命令

Your renamed winsw.exe binary also accepts the following commands:

  • install to install the service to Windows Service Controller. This command requires some preliminary steps described in the Installation Guide.
  • uninstall to uninstall the service. The opposite operation of above.
  • start to start the service. The service must have already been installed.
  • stop to stop the service.
  • restart to restart the service. If the service is not currently running, this command acts like start.
  • status to check the current status of the service.
  • This command prints one line to the console.
  • NonExistent indicates the service is not currently installed
  • Started to indicate the service is currently running
  • Stopped to indicate that the service is installed but not currently running.

winsw.xml

    <depend>Eventlog</depend>
    <depend>W32Time</depend>
   <argument>arg1</argument>
    <argument>arg2</argument>
    <argument>arg3</argument>
    <executable>catalina.sh</executable>
    <startargument>jpda</startargument>
    <startargument>run</startargument>
    
    <stopexecutable>catalina.sh</stopexecutable>
    <stopargument>stop</stopargument>
 <stoptimeout>10sec</stoptimeout>
 <env name="HOME" value="c:\abc" />
   <interactive />
    <download from="http://example.com/some.dat" to="%BASE%\some.dat" />
    
    <download from="http://example.com/some.dat" to="%BASE%\some.dat" failOnError="true"/>

    <download from="https://example.com/some.dat" to="%BASE%\some.dat" auth="sspi" />

    <download from="https://example.com/some.dat" to="%BASE%\some.dat" failOnError="true"
              auth="basic" username="aUser" password="aPassw0rd" />

    <download from="http://example.com/some.dat" to="%BASE%\some.dat"
              auth="basic" unsecureAuth="true"
              username="aUser" password="aPassw0rd" />
    <onfailure action="restart" delay="10 sec"/>
    <onfailure action="restart" delay="20 sec"/>
    <onfailure action="reboot" />
 <onfailure action="restart" />
 <resetfailure>1 hour</resetfailure>
    <serviceaccount>
       <domain>YOURDOMAIN</domain>
       <user>useraccount</user>
       <password>Pa55w0rd</password>
       <allowservicelogon>true</allowservicelogon>
    </serviceaccount>
 <workingdirectory>C:\application</workingdirectory>

*Optionally specify the scheduling priority of the service process (equivalent of Unix nice) Possible values are idle, belownormal, normal, abovenormal, high, realtime (case insensitive.)
 <priority>idle</priority>

<stopparentprocessfirst>true</stopparentprocessfirst>

spring boot

    <service>
      <id>jenkins</id>
      <name>Jenkins</name>
      <description>This service runs Jenkins continuous integration system.</description>
      <env name="JENKINS_HOME" value="%BASE%"/>
      <executable>java</executable>
      <arguments>-Xrs -Xmx256m -jar "%BASE%\jenkins.war" --httpPort=8080</arguments>
      <logmode>rotate</logmode>
    </service>

jenkins

    <service>
      <id>jenkins</id>
      <name>Jenkins</name>
      <description>This service runs Jenkins continuous integration system.</description>
      <env name="JENKINS_HOME" value="%BASE%"/>
      <executable>java</executable>
      <arguments>-Xrs -Xmx256m -jar "%BASE%\jenkins.war" --httpPort=8080</arguments>
      <logmode>rotate</logmode>
    </service>

nginx

<?xml version="1.0" encoding="UTF-8" ?>
<service>

  <id>nginx</id>

  <name>nginx</name>

  <description>nginx</description>

  <executable>D:\server\nginx\nginx.exe</executable>

  <logpath>D:\server\nginx</logpath>

  <logmode>roll</logmode>

  <depend></depend>

  <startargument></startargument>

  <stopargument>-s stop</stopargument>

</service>

winsw.exe.config

<configuration>
    <startup>
      <supportedRuntime version="v2.0.50727" />
      <supportedRuntime version="v4.0" />
    </startup>
  </configuration>