pm2 deploy fast

Published on

I found it. It found me…


I came across the only documentation about cloning a git repo with the --depth option, to create a “shallow” copy with the specified number of commits truncated from HEAD.

  if test <b>fetch != "fast";</b> then
    log "full fetch"
    run "git clone $repo $path/source"
    log "fast fetch"
    run "git clone <b>--depth=5</b> --branch $branch $repo $path/source"

Found in the source code of pm2-deploy.

Apart from the IRRATIONAL INVERTED IF STATEMENT ™ there, it seems to do it’s job. (Why wouldn’t you simply test for the truthy condition and invert both branches?)

Usage in pm2 ecosystem.config.js

I found that you can just specify "fetch": "fast" in your pm2 ecosystem configuration.

This means that it would fetch the last 5 commits from the HEAD (as you can see above).

Good enough for me.

  deploy : {
    production : {
      <b>fetch: 'fast',</b>
      user: 'node',
      host: '',
      ref: 'origin/master',
      repo: '[email protected]:repo.git',
      path: '/app',
      'post-deploy': 'npm install && pm2 reload ecosystem.config.js --env production'

Here, have a slice of pizza 🍕