【问题标题】:pm2: command not found if used in travis-cipm2:如果在 travis-ci 中使用,则找不到命令
【发布时间】:2019-03-05 15:16:36
【问题描述】:

我在 shell 中使用 pm2,它工作正常。但是当我将它添加到.travis.yml 时,它会显示给我

$ pm2 restart index.js
No command 'pm2' found

pm2 在/usr/local/bin 中,当我回显$PATH 时,它包含路径/usr/local/bin。我对此一无所知。

.travis.yml

language: node_js
node_js:
- 8.9.1
branchs:
  only:
  - master
cache:
  apt: true
  directories:
  - node_modules
install:
- git pull
- rm -f package-lock.json && npm install
script:
- echo $PATH
- pm2 restart index.js
after_success:
- chmod 600 ~/.ssh/id_rsa
before_install:
- openssl aes-256-cbc -K $encrypted_a46a360c8512_key -iv $encrypted_a46a360c8512_iv
  -in id_rsa.enc -out ~/.ssh/id_rsa -d

【问题讨论】:

标签: node.js travis-ci pm2


【解决方案1】:

我认为您将构建容器与您希望运行最终应用的实际服务器混为一谈。

Travis 构建项目inside a VM/Container,并在 Travis 构建结束时结束。 PM2 应该在托管应用程序的实际 Web 服务器上安装和运行。

所以,从 Travis ci 你可能应该:

  1. 通过 ssh 将最新的项目文件上传到实际服务器。
  2. 通过 ssh 在实际服务器上运行 pm2。

以下是这些方面的内容:https://oncletom.io/2016/travis-ssh-deploy/

【讨论】:

  • 这是否意味着我只能在 .travis.yml 中运行 git pull。每次我需要用 shell 运行 pm2。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-09-30
  • 1970-01-01
  • 2021-12-07
  • 2013-05-16
  • 2016-11-06
相关资源
最近更新 更多