嗨,我刚刚在 AWS 服务器上学习和实现 Nodejs 项目的 github 操作。我已经执行了所有命令。节点应用程序正在运行,并且可以通过客户端访问。
我已经使用 runner 添加了 Github 操作,无需 pm2 restart 命令也可以。现在我已经从 AWS EC2 启动了服务器并在 pm2 上运行良好。但是在添加命令时,
pm2 重启命名空间
在 github 工作区文件上失败,我得到
[PM2] Spawning PM2 daemon with pm2_home=/home/ubuntu/.pm2
[PM2] PM2 Successfully daemonized
Use --update-env to update environment variables
Error: RROR] Process or Namespace BackendAPI not found
Error: Process completed with exit code 1.
我的文件是
工作空间:
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
name: Node.js CI/CD
on:
push:
branches: [ "main" ]
jobs:
build:
runs-on: self-hosted
strategy:
matrix:
node-version: [18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: |
touch .env
echo "${{ secrets.PROD_ENV_FILE }}" > .env
- run: pm2 restart BackendAPI
问题是什么?有人知道吗?
实际上有一个小问题,我需要使用 sudo 运行 pm2 命令。
像这样
sudo pm2 重新启动服务器名称