50 lines
861 B
Markdown
50 lines
861 B
Markdown
---
|
|
title: 使用nssm注册glances为服务运行
|
|
createTime: 2025/03/14 22:24:23
|
|
tags:
|
|
- Windows
|
|
categories:
|
|
- 随记
|
|
---
|
|
|
|
1. 下载 nssm
|
|
|
|
[https://nssm.cc/download](https://nssm.cc/download)
|
|
|
|
解压相应的 nssm.exe 到目录
|
|
|
|
2. 配置运行环境
|
|
|
|
```bash
|
|
# 安装环境
|
|
python -m venv venv
|
|
pip install glances fastapi uvicorn jinja2
|
|
# docker支持
|
|
pip install glances[containers]
|
|
# 测试环境
|
|
path/to/venv/Scripts/python.exe -m glances --bind 127.0.0.1 --port 8080 -w -q
|
|
```
|
|
|
|
3. 配置 nssm
|
|
|
|
```bash
|
|
.\nssm.exe install glances
|
|
```
|
|
|
|
在对话框中配置:
|
|
Path: `path/to/venv/Scripts/python.exe`
|
|
Startup Directory: `path/to/venv/Scripts/`
|
|
Augments: `-m glances --bind 127.0.0.1 --port 8080 -w -q`
|
|
|
|
4. 启动服务
|
|
|
|
```bash
|
|
.\nssm.exe start glances
|
|
```
|
|
|
|
5. 设置服务延迟启动
|
|
|
|
```bash
|
|
nssm set glances start SERVICE_DELAYED_AUTO_START
|
|
```
|