npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

snss-types

v1.0.9

Published

基于 Nestjs 的 服务端接口,提供文件数据处理解析传输等服务接口

Readme

PM2 开机自启持久化配置指南

PM2 支持生成系统启动脚本,实现服务器重启后自动恢复进程列表,支持主流 Linux、macOS、Windows 系统,兼容多种初始化系统。

一、支持的初始化系统

PM2 可通过 pm2 startup 自动检测系统,对应关系如下: | 初始化系统 | 适用系统 | |------------|----------| | systemd | Ubuntu ≥16、CentOS ≥7、Arch、Debian ≥7 | | upstart | Ubuntu ≤14 | | launchd | macOS(Darwin) | | openrc | Gentoo Linux、Arch Linux | | rcd | FreeBSD | | systemv | CentOS 6、Amazon Linux |

二、核心操作命令

1. 生成开机自启脚本

直接执行命令,PM2 会提示需要 root 权限:

pm2 startup

执行后会输出带权限的完整命令,复制粘贴到终端执行(无需手动修改参数):

# 示例输出命令,直接复制执行即可
sudo su -c "env PATH=$PATH:/home/unitech/.nvm/versions/node/v14.3/bin pm2 startup <distribution> -u <user> --hp <home-path>"

✅ 可选:自定义服务名称

pm2 startup --service-name 自定义服务名

2. 保存当前应用进程列表

启动所有需要持久化的应用后,执行保存命令,重启后会自动恢复:

pm2 save

3. 手动恢复进程

如需手动还原已保存的进程列表,执行:

pm2 resurrect

4. 禁用开机自启

删除 PM2 启动配置,关闭开机自启:

pm2 unstartup

三、进阶配置

1. Node.js 版本升级后更新启动脚本

升级 Node 后,需重新生成 PM2 启动脚本,确保使用最新 Node 二进制文件:

# 1. 先禁用旧配置
pm2 unstartup
# 2. 重新生成新配置
pm2 startup

2. 指定运行用户

以指定用户执行 PM2 启动脚本(替换用户名和家目录):

pm2 startup ubuntu -u www --hp /home/ubuntu

3. 手动指定初始化系统

如需强制指定平台/初始化系统,使用以下命令:

pm2 startup [ubuntu|ubuntu14|ubuntu16|ubuntu18|ubuntu20|centos|centos6|arch|macos|systemd|upstart|launchd|openrc|rcd]

四、Systemd 系统检查命令(适用于 Ubuntu16+/CentOS7+)

# 查看 PM2 服务是否添加成功
systemctl list-units | grep pm2

# 查看 PM2 服务日志
journalctl -u pm2-<用户名>

# 查看 systemd 配置文件
systemctl cat pm2-<用户名>

# 分析系统启动耗时
systemd-analyze plot > output.svg

Systemd 优化:等待网络联机后启动 PM2

编辑 PM2 系统服务文件,添加以下配置,避免网络未就绪导致应用启动失败:

[Unit]
Wants=network-online.target
After=network.target network-online.target

[Install]
WantedBy=multi-user.target network-online.target

五、Windows 系统开机自启

  1. 执行以下命令并按回车确认
npx pm2-service-install -n PM2
  1. 保存当前 PM2 进程列表,安装好服务后,需要把当前正在运行的应用保存下来,这样开机后服务才能自动拉起它们:
pm2 save

以后只要用 PM2 启动或停止了新的应用,记得再次执行 pm2 save 来更新开机自启列表。

六、完整操作流程(推荐)

  1. 启动所有需要持久化的 Node.js 应用
  2. 保存进程列表:pm2 save
  3. 生成开机自启脚本:pm2 startup(复制输出命令执行)
  4. 重启服务器验证:reboot
  5. 重启后查看进程:pm2 list

package.json

{
  "name": "satellite-network-simulation-server",
  "private": true,
  "version": "1.0.0",
  "description": "Nest TypeScript starter repository",
  "license": "MIT",
  "scripts": {
    "dev": "nest start --watch",
    "build": "nest build",
    "start": "node dist/src/main.js",
    "pm2:start": "npx pm2 start ecosystem.config.js --name nest-app",
    "pm2:list": "npx pm2 list",
    "pm2:status": "npx pm2 show nest-app",
    "pm2:stop": "npx pm2 stop nest-app",
    "pm2:delete": "npx pm2 delete nest-app",
    "pm2:logs": "npx pm2 logs nest-app --lines 1000"
  },
  "engines": {
    "npm": ">=10.0.0",
    "node": ">=20.0.0"
  },
  "dependencies": {
    "@nestjs/common": "^11.0.17",
    "@nestjs/config": "^4.0.4",
    "@nestjs/core": "^11.0.1",
    "@nestjs/platform-express": "^11.1.11",
    "@nestjs/platform-socket.io": "^11.1.19",
    "@nestjs/platform-ws": "^11.1.19",
    "@nestjs/swagger": "^11.4.2",
    "@nestjs/typeorm": "^11.0.1",
    "@nestjs/websockets": "^11.1.19",
    "class-validator": "^0.15.1",
    "dotenv": "^17.4.2",
    "mysql2": "^3.22.3",
    "reflect-metadata": "^0.2.2",
    "rxjs": "^7.8.1",
    "typeorm": "^0.3.29",
    "ws": "^8.20.1"
  },
  "devDependencies": {
    "@eslint/eslintrc": "^3.2.0",
    "@eslint/js": "^9.18.0",
    "@nestjs/cli": "^11.0.0",
    "@nestjs/schematics": "^11.0.0",
    "@nestjs/testing": "^11.0.1",
    "@swc/cli": "^0.6.0",
    "@swc/core": "^1.10.8",
    "@types/express": "^5.0.0",
    "@types/multer": "^2.1.0",
    "@types/node": "^22.10.7",
    "@types/supertest": "^6.0.2",
    "eslint": "^9.18.0",
    "eslint-config-prettier": "^10.0.1",
    "eslint-plugin-prettier": "^5.2.3",
    "globals": "^15.14.0",
    "pm2": "^7.0.1",
    "prettier": "^3.4.2",
    "source-map-support": "^0.5.21",
    "supertest": "^7.0.0",
    "ts-loader": "^9.5.2",
    "ts-node": "^10.9.2",
    "tsconfig-paths": "^4.2.0",
    "typescript": "5.7.3",
    "typescript-eslint": "^8.20.0"
  },
  "pnpm": {
    "onlyBuiltDependencies": ["@nestjs/core", "@swc/core"]
  }
}