The window server environment registers the springboot project jar package as a window service self-starting

Table of contents

1. Download the WinSW tool

2. Create a new xml file of Window Service information

3. Rename xml and exe

4. Install and uninstall services

5. Modify configuration file

6. Commonly used commands (note that winsw is the exe name

1. Download the WinSW tool

Download winsw https://github.com/winsw/winsw/releases

2. Create a new xml file of Window Service information

<!-- 根元素必须是service标签 -->

<service>
       <!-- 指定在Window系统内部使用的识别服务的ID,唯一 -->
       <id>0319bf052a9b42a1a6a392cd579ee456</id>
       <!-- 服务的名称 -->
       <name>EurekaServer</name>
       <!-- 描述 -->
       <description>注册中心Eureka Service</description>
       <!-- java环境变量 -->
       <env name="JAVA_HOME" value="%JAVA_HOME%"></env>
       <!-- 指定要启动的可执行文件 -->
       <executable>java</executable>
       <arguments>-Dfile.encoding=utf-8 -Xmx256M -Xms256M  -jar "F:\springboot\eureka-service\eureka-service-1.0.jar" --spring.profiles.active=prod --spring.config.location=./application-prod.yml</arguments>
       <!-- 开机启动 -->
       <startmode>Automatic</startmode>
       <!-- 日志配置 -->
       <logpath>%BASE%/log</logpath>
       <logmode>rotate</logmode>

</service>

3. Rename xml and exe

The downloaded WinSW-x64.exe and the newly created xml file must have the same name

4. Install and uninstall services

To uninstall, you need to close the service before executing the uninstall command. Otherwise, it will still be in the service list after refreshing, but the service has been marked for deletion. If you uninstall the service after closing the service, the service name will not appear in the service list after refreshing.

5. Modify configuration file

Modifying the configuration file information will not take effect immediately, and the configuration information will not take effect until the service is restarted. Let me take modifying the service port as an example.

Change the eureka port to 8000 to take effect after the service restarts

6. Commonly used commands (note that winsw is the exe name)

winsw install:安装服务
winsw uninstall:卸载服务
winsw start:开启服务
winsw stop:停止服务
winsw restart:重新启动服务
winsw status:检查服务的当前状态

Guess you like

Origin blog.csdn.net/m0_48983233/article/details/131132418