Turn Nacos into a Windows system service to realize self-starting at boot

foreword

This article will introduce you how to use the WinSW tool to package Nacos as a Windows system service and realize the convenient function of self-starting at boot. By installing Nacos as a system service, you will get rid of the trouble of manually starting each time, thereby improving deployment efficiency and system stability.

Download WinSW

WinSW (Windows Service Wrapper is an open source Windows service wrapper, which can help you package applications into system services, and realize the function of self-starting when booting.

Download WinSW-x64.exe ( ⬇️ more version downloads ) and sample-minimal.xml

Configure WinSW

  1. Rename WinSW-x64.exe to nacos-service.exesample-minimal.xm nacos-service.xmland place the renamed file in D:\middleware\nacos\binthe directory

  1. Modify the configuration of nacos-service.xmlthe file as follows:
<service>
  <!-- 唯一服务ID-->
  <id>nacos</id>
  <!-- 显示服务的名称 -->
  <name>Nacos Service</name>
  <!-- 服务描述 -->
  <description>Nacos 服务</description>
  <!-- 日志路径-->
  <logpath>D:\middleware\nacos\bin\logs</logpath>
  <!-- 日志模式 -->
  <logmode>roll</logmode>
  <!-- 指定启动可执行文件 -->
  <executable>D:\middleware\nacos\bin\startup.cmd</executable>
  <!-- 启动参数(-m standalone 单机启动)-->
  <arguments>-m standalone</arguments>
  <!-- 开机启动 -->
  <startmode>Automatic</startmode>
  <!-- 指定停止可执行文件 -->
  <stopexecutable>D:\middleware\nacos\bin\shutdown.cmd</stopexecutable>
</service>

Install and start Nacos service

CMD switch to D:\middleware\nacos\binthe directory , execute the following command to complete the installation and start of the service

# 安装服务
nacos-service.exe install
# 启动服务
nacos-service.exe start

You can see the Nacos service in the Windows system service list (it has been verified that it can start automatically at boot)

Visit the Nacos console to verify whether the service has started successfully

other commands

# 删除服务
nacos-service.exe uninstall
# 查看状态
nacos-service.exe status
# 重启服务
nacos-service.exe restart

contact me

If you have any questions or need further discussion while reading this article, you can contact me through the contact information provided on the homepage of the open source organization. I am happy to provide technical support and welcome you to join our technical exchange group. Looking forward to sharing and discussing technical topics with you!
There is an open source organization: https://gitee.com/youlaiorg

Guess you like

Origin blog.csdn.net/u013737132/article/details/130910298