目录
一、 准备文件
以注册java程序 服务为例
2、下载Windows Service Wrapper
winsw是一款可将可执行程序安装成Windows Service的开源工具,
百度网盘链接:https://pan.baidu.com/s/1ZThpISNMZW895P5m9dKySg 提取码:8888
蓝奏云链接:https://wws.lanzoui.com/iJTVrvmu8cd
github:https://github.com/kohsuke/winsw/releases
需要将winsw执行程序 跟xml 还有需要注册的服务名,改成同样的名字:
修改spider-1.0.xml文件内容
<configuration>
<id>SpiderService</id>
<name>SpiderService</name>
<description>This is Spider service.</description>
<executable>java</executable>
<arguments>-jar spider-1.0.jar</arguments>
<!-- 开机启动 -->
<startmode>Automatic</startmode>
<!-- 日志配置 -->
<logpath>logs/service</logpath>
<logmode>rotate</logmode>
</configuration>
配置完成后,命令行进入winsw所在的文件夹,CMD执行“spider-1.0.exe install”,就注册服务了。
如果不再需要这个服务,使用spider-1.0.exe uninstall即可卸载服务。start启动和stop关闭服务