https://github.com/unitech/pm2-deploy
Deploy part of PM2
https://github.com/unitech/pm2-deploy
Last synced: 8 months ago
JSON representation
Deploy part of PM2
- Host: GitHub
- URL: https://github.com/unitech/pm2-deploy
- Owner: Unitech
- License: mit
- Created: 2014-06-16T12:23:26.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2020-11-13T22:38:52.000Z (about 5 years ago)
- Last Synced: 2025-05-10T09:24:24.998Z (8 months ago)
- Language: JavaScript
- Homepage: http://pm2.keymetrics.io/docs/usage/deployment/
- Size: 106 KB
- Stars: 178
- Watchers: 6
- Forks: 70
- Open Issues: 100
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Deploy system for PM2
This is the module that allows to do `pm2 deploy`.
Documentation: http://pm2.keymetrics.io/docs/usage/deployment/
[](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)
## Instalation
$ npm install pm2-deploy
## Programmatic Usage
```js
var deployForEnv = require('pm2-deploy').deployForEnv;
// Define deploy configuration with target environments
var deployConfig = {
prod: {
user: 'node',
host: '212.83.163.168',
ref: 'origin/master',
repo: 'git@github.com:Unitech/eip-vitrine.git',
path: '/var/www/test-deploy'
},
dev: {
user: 'node',
host: '212.83.163.168',
ref: 'origin/master',
repo: 'git@github.com:Unitech/eip-vitrine.git',
path: '/var/www/test-dev'
}
};
// Invoke deployment for `dev` environment
deployForEnv(deployConfig, 'dev', [], function (err, args) {
if (err) {
console.error('Deploy failed:', err.message);
return console.error(err.stack);
}
console.log('Success!');
});
// Rollback `prod` environment
deployForEnv(deployConfig, 'prod', ['revert', 1], function (err, args) {
if (err) {
console.error('Rollback failed:', err.message);
return console.error(err.stack);
}
console.log('Success!');
});
```
## API
#### Table of Contents
- [deployForEnv](#deployforenv)
- [Parameters](#parameters)
- [DeployCallback](#deploycallback)
- [Parameters](#parameters-1)
### deployForEnv
Deploy to a single environment
#### Parameters
- `deployConfig` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** object containing deploy configs for all environments
- `env` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** the name of the environment to deploy to
- `args` **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** custom deploy command-line arguments
- `cb` **[DeployCallback](#deploycallback)** done callback
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** return value is always `false`
### DeployCallback
Type: [Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)
#### Parameters
- `error` **[Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)** deployment error
- `args` **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** custom command-line arguments provided to deploy