Pm2: PM2 always checkout branch/tags to default branch

Created on 17 Jul 2018  ยท  3Comments  ยท  Source: Unitech/pm2

this issue have some similarity to #3636, but for my case pm2 has successfully checked out a specific branch from upstream but merged it wrongly to the default branch

What's going wrong?

when execute pm2 deploy staging and pm2 deploy staging update pm2 checkout/fetch the correct branch and tags specified in ecosystem.config.js but merged it wrongly in to default branch.

How could we reproduce this issue?

  1. in ecosystem > deploy > staging: set ref: 'origin/production'
  2. pm2 deploy staging setup
  3. pm2 deploy staging
  4. run git branch at remote server
  5. it shown develop which is the default branch (expected production branch)
  6. run git log at remote server, it shown the commits from production (which is correct)

Supporting information

same spec on both deploy server and remote server
git: git version 2.17.0
pm2: 3.0.0
node: v10.6.0
npm: 6.1.0
ubuntu: 18.04 LTS

ecosystem.config.js

module.exports = {
    apps : [{
        name: 'mr-app-api',
        script: '_pm2_app.js',
            cwd: '/opt/st/mr-app-api/source',
        instances: 1,
        exec_mode: 'fork',
        log_date_format: 'YYYY-MM-DD HH:mm:ss',
        max_memory_restart: '200M',
        merge_logs: false,
        ignore_watch: ['[\\/\\\\]\\./', 'log'],
        watch: false,
        env: {
            NODE_ENV: 'development'
        },
        env_staging: {
            NODE_ENV: 'staging'
        }
    }],

    deploy : {
        staging: {
            user: 'ldarren',
            host: '178.64.64.64',
            ref: 'origin/production',
            branch: 'production',
            fetch: '--all',
            repo: '[email protected]:ldarren/mr-app-api.git',
            path: '/opt/st/mr-app-api',
            // Pre-setup command or path to a script on your local machine
            'pre-setup': 'apt-get install git ; ls -la',
            // 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 local executed command"',
            'pre-deploy': 'git fetch --all',
            // post-deploy action
            'post-deploy': 'npm install && pm2 reload ecosystem.config.js --env staging'
        }
    }
};
$ pm2 report
===============================================================================
--- PM2 REPORT (Mon Jul 16 2018 23:38:33 GMT+0000 (Coordinated Universal Time)) 
===============================================================================
--- Daemon -------------------------------------------------
pm2d version         : 3.0.0
node version         : 10.6.0
node path            : /home/ldarren/.nvm/versions/node/v10.6.0/bin/pm2
argv                 : /home/ldarren/.nvm/versions/node/v10.6.0/bin/node,/home/ldarren/.nvm/versions/node/v10.6.0/lib/node_modules/pm2/lib/Daemon.js
argv0                : node
user                 : ldarren
uid                  : 1000
gid                  : 1000
uptime               : 414min
===============================================================================
--- CLI ----------------------------------------------------
local pm2            : 3.0.0
node version         : 10.6.0
node path            : /home/ldarren/.nvm/versions/node/v10.6.0/bin/pm2
argv                 : /home/ldarren/.nvm/versions/node/v10.6.0/bin/node,/home/ldarren/.nvm/versions/node/v10.6.0/bin/pm2,report
argv0                : node
user                 : ldarren
uid                  : 1000
gid                  : 1000
===============================================================================
--- System info --------------------------------------------
arch                 : x64
platform             : linux
type                 : Linux
cpus                 : Intel(R) Xeon(R) CPU E5-2697A v4 @ 2.60GHz
cpus nb              : 1
freemem              : 176345088
totalmem             : 1033388032
home                 : /home/ldarren
===============================================================================
--- PM2 list -----------------------------------------------
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ App name   โ”‚ id โ”‚ mode โ”‚ pid   โ”‚ status โ”‚ restart โ”‚ uptime โ”‚ cpu โ”‚ mem       โ”‚ user   โ”‚ watching โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ mr-app-api โ”‚ 0  โ”‚ fork โ”‚ 19617 โ”‚ online โ”‚ 3       โ”‚ 6h     โ”‚ 0%  โ”‚ 51.0 MB   โ”‚ mrtech โ”‚ disabled โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
===============================================================================
--- Daemon logs --------------------------------------------
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ App name   โ”‚ id โ”‚ mode โ”‚ pid   โ”‚ status โ”‚ restart โ”‚ uptime โ”‚ cpu โ”‚ mem       โ”‚ user   โ”‚ watching โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ mr-app-api โ”‚ 0  โ”‚ fork โ”‚ 19617 โ”‚ online โ”‚ 3       โ”‚ 6h     โ”‚ 0%  โ”‚ 51.0 MB   โ”‚ ldarren โ”‚ disabled โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
Pending Release Deploy

Most helpful comment

It should work with pm2 3.1.0

$ npm install pm2@latest -g
$ pm2 update

All 3 comments

PR welcome, the deployment system is pretty straightforward: https://github.com/Unitech/pm2-deploy/blob/master/deploy

It should work with pm2 3.1.0

$ npm install pm2@latest -g
$ pm2 update

[email protected] published

$ npm install pm2@latest -g
$ pm2 update
Was this page helpful?
0 / 5 - 0 ratings