0%

windows下服务管理-NSSM

NSSM - the Non-Sucking Service Manager

安装

nssm.cc下载exe文件,添加到path环境

添加服务

以gogs服务安装为例子

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
@ECHO off

:: This script relies on nssm.exe to work.
:: Please, download it and make it available on the system path,
:: or copy it to the gogs path.
:: https://nssm.cc/download
:: This script itself should run in the gogs path, too.
:: In case of startup failure, please read carefully the log file.
:: Make sure Gogs work running manually with "gogs web" before running
:: this script.
:: And, please, read carefully the installation docs first:
:: https://gogs.io/docs/installation
:: To unistall the service, run "nssm remove gogs" and restart Windows.

:: Set the folder where you extracted Gogs. Omit the last slash.
SET gogspath=D:\gogs

nssm install gogs "%gogspath%\gogs.exe"
nssm set gogs AppParameters "web"
nssm set gogs Description "A painless self-hosted Git service."
nssm set gogs DisplayName "Gogs - Go Git Service"
nssm set gogs Start SERVICE_DELAYED_AUTO_START
nssm set gogs AppStdout "%gogspath%\gogs.log"
nssm start gogs
pause

nssm install gogsGUI方式安装服务
nssm edit gogs可以打开GUI界面,方便配置

参考文档

  1. http://nssm.cc
  2. https://gogs.io/docs/installation/run_as_windows_service
  3. nssm --help