Unitech / pm2-deploy

Deploy part of PM2
http://pm2.keymetrics.io/docs/usage/deployment/
MIT License
178 stars 71 forks source link

Create source folder if not exists #182

Open kounelios13 opened 5 years ago

kounelios13 commented 5 years ago

Hello.I have the following deploy file

module.exports = {
  apps: [{
    name: 'API',
    script: './bin/www',

    // Options reference: https://pm2.io/doc/en/runtime/reference/ecosystem-file/
    args: 'one two',
    instances: 2,
    autorestart: true,
    watch: false,
    max_memory_restart: '400M',
    env: {
      NODE_ENV: 'development'
    },
    env_production: {
      NODE_ENV: 'production',
      PORT: 5000
    }
  }],

  deploy: {
    production: {
      user: 'mkcodergr',
      host: '192.168.1.10',
      ref: 'origin/master',
      repo: 'git@github.com:kounelios13/users-api.git',
      path: '/home/mkcodergr/apps/users-api',
      "pre-deploy-local": "cd $HOME/apps/users-api && mkdir -p source",
      'post-deploy': 'cd $HOME/apps/users-api && echo dir is:$(pwd) && $(npm config get prefix)/bin/pm2 reload $HOME/apps/users-api/ecosystem.config.js --env production --update-env'
    }
  }
};

Now I am trying to deploy using pm2 deploy production.However I have the following problem

If the directory source does not exist in the folder where the repo is cloned fetch fails.Is there any way to ensure source folder exists before fetching the repo?

r-abazari commented 2 years ago

I know it's too late but I leave an answer as maybe another person has the same question.

You can add 'pre-setup' : 'rm -rf $HOME/apps/users-api/source' in your deploy -> production scripts