普通命令注册为windows服务
https://www.cnblogs.com/li150dan/p/15603149.html
作为 Windows 服务运行#
为了将 VictoriaMetrics 作为 Windows 服务运行,需要为 WinSW 创建服务配置,然后根据以下指南将其安装为服务:
创建服务配置:
<service>
<id>VictoriaMetrics</id>
<name>VictoriaMetrics</name>
<description>VictoriaMetrics</description>
<executable>%BASE%\victoria-metrics-windows-amd64-prod.exe"</executable>
<onfailure action="restart" delay="10 sec"/>
<onfailure action="restart" delay="20 sec"/>
<resetfailure>1 hour</resetfailure>
<arguments>-envflag.enable</arguments>
<priority>Normal</priority>
<stoptimeout>15 sec</stoptimeout>
<stopparentprocessfirst>true</stopparentprocessfirst>
<startmode>Automatic</startmode>
<waithint>15 sec</waithint>
<sleeptime>1 sec</sleeptime>
<logpath>%BASE%\logs</logpath>
<log mode="roll">
<sizeThreshold>10240</sizeThreshold>
<keepFiles>8</keepFiles>
</log>
<env name="loggerFormat" value="json" />
<env name="loggerOutput" value="stderr" />
<env name="promscrape_config" value="C:\Program Files\victoria-metrics\promscrape.yml" />
</service>
解释
XML格式
按照本文档安装 WinSW。
通过从提升的 PowerShell 运行以下命令,将 VictoriaMetrics 安装为服务:Install VictoriaMetrics as a service by running the following from elevated PowerShell:
winsw install VictoriaMetrics.xml
Get-Service VictoriaMetrics | Start-Service