安装步骤
winsw(https://github.com/kohsuke/winsw/releases),winsw 是一个可以将任何应用程序注册成服务的软件。
下载 winsw
- 地址:https://github.com/kohsuke/winsw/releases
- 下载的内容:
重命名
将打出的 TMarket.jar 与 winsw.exe 放在同一个目录中,然后将 winsw.exe 重命名为 TMarket.exe
创建配置
创建 TMarket.xml 如下(具体参数参考:https://github.com/kohsuke/winsw):
<service>
<id>TMarket</id>
<name>TMarket-serv</name>
<description>TMarket server for calendar and news message!</description>
<executable>java</executable>
<arguments>-Xmx512m -Xms512m -jar "TMarket.jar"</arguments>
<startmode>Automatic</startmode>
<logpath>logs</logpath>
<logmode>rotate</logmode>
</service>
安装服务与卸载服务
- 安装: TMarket.exe install
- 卸载: TMarket.exe uninstall 或 sc delete TMarket
启动方式
- 方式一: net start TMarket(服务 id)
- 方式二: TMarket.exe start
关闭方式
- 方式一: cmd 中通过 services.msc 进入服务列表操作
- 方式二: 任务管理器中操作
- 方式三: net stop TMarket
- 方式四: TMarket.exe stop
查找服务
winsw的其他命令
- 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.
参考
- https://github.com/kohsuke/winsw
- https://blog.csdn.net/weixin_40411331/article/details/80193376