用NSSM把influxDB安装成windows后台服务

NSSM,是用来将一般程序安装成windows后台服务的工具,使用较为方便,但是在使用还是有几点需要注意的。

1.服务没有窗口,无法进行交互。

2.原版的nssm 执行start stop set命令时不请求系统权限,导致失败,我做了修改,代码见https://github.com/alongL/nssm-2.24-MOD

installService.bat文件内容:

运行时influxdb的输出都在influxd_err.log中

@echo off 

set configfile=%cd%\influxdb.conf
echo %configfile%

rem 将influxd.exe安装为服务,启动时用当前目录下的influxdb.conf作为配置文件
nssm.exe  install  influxd  influxd.exe  -config  %configfile%

rem //////////////////////////////////////////////////////////////////////////
rem 设置服务的描述
rem nssm.exe  set influxd  Description  "influxDB数据库服务后台程序"

rem 设置influxd启动路径为当前路径
 nssm set influxd AppDirectory %cd%

rem 重定位输出和错误
 nssm.exe set influxd AppStdout  %cd%\log\influxd.log
 nssm.exe set influxd AppStderr  %cd%\log\influxd_err.log

启动服务的start.bat就很简单了

nssm.exe  start   influxd 

卸载服务uninstall.bat

nssm.exe  remove   influxd  confirm

我修改后的程序下载链接:

https://download.csdn.net/download/v6543210/10636775

我修改的代码链接:

https://github.com/alongL/nssm-2.24-MOD

nssm官网链接:

http://www.nssm.cc/

猜你喜欢

转载自blog.csdn.net/v6543210/article/details/82227118