1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| module.exports = function (shipit) { require('shipit-deploy')(shipit); require('shipit-pm2')(shipit); require('shipit-cnpmjs')(shipit);
shipit.initConfig({ default: { workspace: '/tmp/github-monitor', deployTo: '/tmp/deploy_to', //服务器的目标路径 repositoryUrl: 'https://github.com/user/repo.git', //git仓库地址 ignores: ['.git', 'node_modules'], //排除的文件 keepReleases: 2, //发布保留的版本数量 deleteOnRollback: false, key: '/path/to/key', shallowClone: true, cnpm: { remote: false } }, dev: { //开发服务器部署 servers: ['user@devServer1', 'user@devServer1'], branch: 'dev' //需要发布的git分支, pm2: { json: 'pm2-dev-app.json' //开发环境的pm2启动配置 } }, prod: { //生产服务器部署 servers: ['user@prodServer1', 'user@prodServer2'], branch: 'master' //需要发布的git分支, pm2: { json: 'pm2-prod-app.json' //生产jam环境的pm2启动配置 } } }); }; pm2-prod-app.json 示例:
{ "apps": [ { "name": "frontend_name", "script": "app.js", "args": "--env=production", "instances": 1, "cwd": "/tmp/production_path/current", "env": { "NODE_ENV": "production", "PORT": "9001" } } ] }
|