项目地址 https://github.com/winsw/winsw
下载3.x的winsw
https://github.com/winsw/winsw/releases/download/v3.0.0-alpha.11/WinSW-x64.exe
我这里是把放到了 C:\WinSW\ 这个目录下
xml配置文件的相关说明:https://github.com/winsw/winsw/blob/v3/docs/xml-config-file.md
这里以nginx和mysql为例
vim mysql.xml
<service>
<id>mysql8</id>
<workingdirectory>D:\mysql8\bin</workingdirectory>
<!-- Path to the executable, which should be started -->
<!-- CAUTION: Don't put arguments here. Use <arguments> instead. -->
<executable>D:\mysql8\bin\mysqld</executable>
</service>
vim nginx.xml
<service>
<id>nginx</id>
<workingdirectory>C:\nginx-1.22.0</workingdirectory>
<!-- Path to the executable, which should be started -->
<!-- CAUTION: Don't put arguments here. Use <arguments> instead. -->
<executable>C:\nginx-1.22.0\nginx.exe</executable>
</service>
dir 查看下当前的项目结构
PS C:\WinSW
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 2024/5/4 14:35 347 mysql.xml
-a---- 2024/5/4 8:10 353 nginx.xml
-a---- 2024/5/4 8:04 18286774 WinSW-x64.exe
PS C:\WinSW
λ .\WinSW-x64.exe install mysql.xml
Installing service 'mysql8 (mysql8)'...
Service 'mysql8 (mysql8)' was installed successfully.
PS C:\WinSW
λ .\WinSW-x64.exe install nginx.xml
Installing service 'nginx (nginx)'...
Service 'nginx (nginx)' was installed successfully.
PS C:\WinSW
λ .\WinSW-x64.exe start nginx.xml
Starting service 'nginx (nginx)'...
Service 'nginx (nginx)' started successfully.
PS C:\WinSW
λ .\WinSW-x64.exe status nginx.xml
Active (running)
PS C:\WinSW
λ .\WinSW-x64.exe start mysql.xml
Starting service 'mysql8 (mysql8)'...
Service 'mysql8 (mysql8)' started successfully.
PS C:\WinSW
λ .\WinSW-x64.exe status mysql.xml
Active (running)
Command | Description |
---|---|
install | Installs the service. |
uninstall | Uninstalls the service. |
start | Starts the service. |
stop | Stops the service. |
restart | Stops and then starts the service. |
status | Checks the status of the service. |
refresh | Refreshes the service properties without reinstallation. |
customize | Customizes the wrapper executable. |
dev | Experimental commands. |
Experimental commands:
Command | Description |
---|---|
dev ps | Draws the process tree associated with the service. |
dev kill | Terminates the service if it has stopped responding. |
dev list | Lists services managed by the current executable. |
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。