pm2 远程发版

栏目: 编程工具 · 发布时间: 7年前

内容简介:在你的git仓库根目录中新建pm2配置文件服务器上的git版本需要在v1.8以上,否则fetch不成功,代码更新不了。可参照CENTOS安装高版本GIT可查看提交记录,回滚到想要的版本

创建配置项

在你的git仓库根目录中新建pm2配置文件 ecosystem.config.js ,如注释所示,或者执行 pm2 init 初始化文件 ecosystem.config.js

module.exports = {
  apps : [{
    //pm2名字
    name: "nextcn",
   //pm2运行脚本
    script: "./app.js",
  //环境变量
    env: {
      NODE_ENV: "development",
    },
    env_production: {
      NODE_ENV: "production",
    }
  }],
  deploy: {
    // "production" is the environment name
    production: {
      // 服务器端SSH key 地址, 默认 $HOME/.ssh
      key: "$HOME/.ssh",
      // SSH user 需配置
      user: "root",
      // SSH host 需配置
      host: ["47.98.138.195"],
      // SSH options with no command-line flag, see 'man ssh'
      // can be either a single string or an array of strings
      ssh_options: "StrictHostKeyChecking=no",
      // GIT remote/branch
      ref: "origin/master",
      // GIT ssh远程地址 需配置
      repo: "git@github.com:raoenhui/next-site-cn.git",
      // 放入服务器端地址 需配置
      path: "/ice/pm2",
      // Pre-setup command or path to a script on your local machine
      "pre-setup": "echo 'This is a pre-setup command'",
      // Post-setup commands or path to a script on the host machine
      // eg: placing configurations in the shared dir etc
      "post-setup": "ls -la",
      // pre-deploy action
      "pre-deploy-local": "echo 'This is a pre-deploy-local command'",
      // post-deploy action
      "post-deploy": "npm install && pm2 reload ecosystem.config.js --env production'"
    },
  }
}

安装

pm2 deploy production setup

服务器上的git版本需要在v1.8以上,否则fetch不成功,代码更新不了。可参照CENTOS安装高版本GIT pm2 远程发版

更新

pm2 deploy production update

回滚

pm2 deploy production revert 1

可查看提交记录,回滚到想要的版本 pm2 deploy production list

强制提交

pm2 deploy production --force

当你代码有修改但是不想提交时可以强制发布

参考资料

Happy coding .. :)


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

The Effective Engineer

The Effective Engineer

Edmond Lau / The Effective Bookshelf, Palo Alto, CA. / 2015-3-19 / USD 39.00

Introducing The Effective Engineer — the only book designed specifically for today's software engineers, based on extensive interviews with engineering leaders at top tech companies, and packed with h......一起来看看 《The Effective Engineer》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

html转js在线工具
html转js在线工具

html转js在线工具