Preface
As we all know, if you want to start nacos in a Windows environment, you need to run startup.cmd in the bin directory. This startup method needs to ensure that the cmd window is always open. As long as this window is closed, the nacos service will stop.
Therefore, in order to avoid artificially closing the window by mistake, registering nacos as a winserver is a good choice. This not only ensures that nacos is always running in the background, but also allows you to customize the startup and self-starting through the registered service name.
1. nacos download and installation
Tutorial: nacos download and installation
2. Download WinSW
Plug-in download
address: github download plug-in
3. In the bin directory of nacos, copy the downloaded winsw.exe to this directory and rename it to NacosWinService.exe.
4. Create a new configuration file NacosWinService.xml in the bin directory of nacos and write the relevant configuration of the service:
<?xml version="1.0" encoding="UTF-8"?>
<service>
<id>NacosWinService</id>
<name>NacosWinService</name>
<description>NacosWinService</description>
<executable>D:\software\nacos-server-1.2.1\nacos\bin\startup.cmd</executable>
<arguments>-m standalone</arguments>
<logpath>D:\software\nacos-server-1.2.1\nacos\bin\serviceLogs</logpath>
</service>
5. Go to the nacos bin directory with cmd as administrator and execute the following command:
1. Install the service: NacosWinService.exe install
2. Start the service: net start NacosWinService