Windows添加自定义服务
1.新建文件
新建xml文件 命名 Name-service.xml
<service>
<!-- ID of the service. It should be unique across the Windows system-->
<id>ServerID</id>
<!-- Display name of the service -->
<name>ServerName</name>
<!-- Service description -->
<description>ServerDescription</description>
<!-- Path to the executable, which should be started -->
<executable>D:\Name.exe</executable>
</service>
里面存放以上内容
2.下载应用
下载链接: https://github.com/winsw/winsw/releases/tag/v2.11.0
3.安装服务
将下载的文件名称改为新建的xml名称,将此文件移到xml里面配置的项目路径中
在当前目录下 CMD进入目录,然后执行命令
Name-service.exe install
系统成功了有提示,失败请看提示或相关log文件
4.启动服务
到windows service里面找到 使用启动按钮, 编辑按钮设置为 自动启动
启动失败一般是端口被占用,需要去修改 或看log 去解决
一般错误都是程序使用错误自行排查