|
1 | | - |
2 | 1 | # Deploy system for PM2 |
3 | 2 |
|
4 | | -Documentation: [http://pm2.keymetrics.io/docs/usage/deployment/](http://pm2.keymetrics.io/docs/usage/deployment/) |
| 3 | +Documentation: <https://pm2.io/doc/en/runtime/guide/easy-deploy-with-ssh/> |
| 4 | + |
| 5 | +[](https://travis-ci.org/Unitech/pm2-deploy) [](https://npm.im/pm2-deploy) [](https://packagephobia.now.sh/result?p=pm2-deploy) [](https://github.com/Unitech/pm2-deploy/blob/master/LICENSE) [](https://github.com/Flet/semistandard) |
| 6 | + |
| 7 | +## Instalation |
| 8 | + |
| 9 | + $ npm install pm2-deploy |
| 10 | + |
| 11 | +## Usage |
| 12 | + |
| 13 | +```js |
| 14 | +var deployForEnv = require('pm2-deploy').deployForEnv; |
| 15 | + |
| 16 | +// Define deploy configuration with target environments |
| 17 | +var deployConfig = { |
| 18 | + prod: { |
| 19 | + user: 'node', |
| 20 | + host: '212.83.163.168', |
| 21 | + ref: 'origin/master', |
| 22 | + repo: 'git@github.com:Unitech/eip-vitrine.git', |
| 23 | + path: '/var/www/test-deploy' |
| 24 | + }, |
| 25 | + dev: { |
| 26 | + user: 'node', |
| 27 | + host: '212.83.163.168', |
| 28 | + ref: 'origin/master', |
| 29 | + repo: 'git@github.com:Unitech/eip-vitrine.git', |
| 30 | + path: '/var/www/test-dev' |
| 31 | + } |
| 32 | +}; |
| 33 | + |
| 34 | +// Invoke deployment for `dev` environment |
| 35 | +deployForEnv(deployConfig, 'dev', [], function (err, args) { |
| 36 | + if (err) { |
| 37 | + console.error('Deploy failed:', err.message); |
| 38 | + return console.error(err.stack); |
| 39 | + } |
| 40 | + console.log('Success!'); |
| 41 | +}); |
| 42 | + |
| 43 | +// Rollback `prod` environment |
| 44 | +deployForEnv(deployConfig, 'prod', ['revert', 1], function (err, args) { |
| 45 | + if (err) { |
| 46 | + console.error('Rollback failed:', err.message); |
| 47 | + return console.error(err.stack); |
| 48 | + } |
| 49 | + console.log('Success!'); |
| 50 | +}); |
| 51 | +``` |
| 52 | + |
| 53 | +## API |
| 54 | + |
| 55 | +<!-- Generated by documentation.js. Update this documentation by updating the source code. --> |
| 56 | + |
| 57 | +#### Table of Contents |
| 58 | + |
| 59 | +- [deployForEnv](#deployforenv) |
| 60 | + - [Parameters](#parameters) |
| 61 | +- [DeployCallback](#deploycallback) |
| 62 | + - [Parameters](#parameters-1) |
| 63 | + |
| 64 | +### deployForEnv |
| 65 | + |
| 66 | +Deploy to a single environment |
| 67 | + |
| 68 | +#### Parameters |
| 69 | + |
| 70 | +- `deployConfig` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** object containing deploy configs for all environments |
| 71 | +- `env` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** the name of the environment to deploy to |
| 72 | +- `args` **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** custom deploy command-line arguments |
| 73 | +- `cb` **[DeployCallback](#deploycallback)** done callback |
| 74 | + |
| 75 | +Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** return value is always `false` |
| 76 | + |
| 77 | +### DeployCallback |
| 78 | + |
| 79 | +Type: [Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function) |
| 80 | + |
| 81 | +#### Parameters |
5 | 82 |
|
6 | | -[](http://badge.fury.io/js/pm2) |
7 | | -[](https://travis-ci.org/Unitech/pm2-deploy) |
| 83 | +- `error` **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** deployment error |
| 84 | +- `args` **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** custom command-line arguments provided to deploy |
0 commit comments