使用pm2管理进程

pm2

安装

npm install pm2 -g

常用命令:

pm2 list              # 查看所有服务
pm2 restart my_app    # 重启指定服务
pm2 logs              # 查看所有日志
pm2 stop all          # 停止全部服务
pm2 save              # 保存配置用于重启自动恢复
pm2 startup           # 设置系统开机自启

一些参数:

--cwd path	                # 从路径 path 运行目标脚本
-n --name name	            # 在进程列表中为进程设置一个名称
--interpreter interpreter	# 设置一个特定的解释器用于执行应用程序, 默认值:node

我启动了多个服务,使用 powershell 进行控制,下面是start_all.ps1

pm2 delete all
pm2 start fit_sin.py --name fit_sin --interpreter python --cwd ./fit_sin
pm2 start knn_predict.py --name knn_predict --interpreter python --cwd ./knn_predict
pm2 start KnowIt.py --name KnowIt --interpreter python --cwd ./KnowIt
pm2 start KnowIt_Dev.py --name KnowIt_Dev --interpreter python --cwd ./KnowIt_Dev
pm2 imonit

imonit

其他:Windows11 下的 WMIC

WMIC 已经废弃,Windows11 已移除WMI command line (WMIC) utility deprecation: Next steps

install wmic


comment: