Unitech / pm2-deploy

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

Deploy failed when deploy #150

Closed apoutchika closed 6 years ago

apoutchika commented 6 years ago

Hello,

When i deploy my project, pm2 deploy output is "Deploy failed", with not other errors or logs.

This work fine when i start my project, but now (after node update ?) pm2 deploy output is always :

$ pm2 deploy release
Deploy failed

My ecosystem.config.js :

module.exports = {
  apps: [
    {
      name: 'app',
      script: 'server.js',
      env: {
        COMMON_VARIABLE: 'true',
        PORT: 3001
      },
      env_production: {
        NODE_ENV: 'production'
      },
      exec_mode: 'cluster',
      instances: 'max'
    }
  ],
  deploy: {
    release: {
      user: 'node8',
      host: {
        port: '7891',
        host: 'mydomain.com'
      },
      ref: 'origin/release',
      repo: 'git@myrepo.com:myapp.git',
      path: '/home/node8/myapp/',
      'post-deploy': 'npm i && npm run build && pm2 startOrGracefulReload ecosystem.config.js --env production'
    }
  }
}

My versions :

Thank you in advance, Apoutchika

phra commented 6 years ago

i see that there are some node8 references in the config.. are they still valid after your upgrade?

do you confirm that is working with node 8.x.x but failing with node 9.x.x ? did you also tried to remove and setup again the deployment?

vmarchaud commented 6 years ago

Sadly there are no verbose log here, can you try to git clone the pm2 repo, add a console.log(err) here and use the binary in ./bin/pm2 where you cloned the repo ?

apoutchika commented 6 years ago

I try with node 8, i have same issue.

The console log return this :

Deploy failed
{ Error
    at new ValidationError (/tmp/pm2/node_modules/tv4/tv4.js:1461:12)
    at ValidatorContext.createError (/tmp/pm2/node_modules/tv4/tv4.js:359:14)
    at ValidatorContext.validateType (/tmp/pm2/node_modules/tv4/tv4.js:751:14)
    at ValidatorContext.validateBasic (/tmp/pm2/node_modules/tv4/tv4.js:721:19)
    at ValidatorContext.validateAll (/tmp/pm2/node_modules/tv4/tv4.js:599:19)
    at ValidatorContext.validateObjectProperties (/tmp/pm2/node_modules/tv4/tv4.js:1010:21)
    at ValidatorContext.validateObject (/tmp/pm2/node_modules/tv4/tv4.js:961:11)
    at ValidatorContext.validateAll (/tmp/pm2/node_modules/tv4/tv4.js:603:11)
    at Object.validate (/tmp/pm2/node_modules/tv4/tv4.js:1573:24)
    at Object.deployForEnv (/tmp/pm2/node_modules/pm2-deploy/deploy.js:52:12)
  message: 'Invalid type: object (expected string/array)',
  params: { type: 'object', expected: 'string/array' },
  code: 0,
  dataPath: '/host',
  schemaPath: '/properties/host/type',
  subErrors: null,
  stack: 'Error\n    at new ValidationError (/tmp/pm2/node_modules/tv4/tv4.js:1461:12)\n    at ValidatorContext.createError (/tmp/pm2/node_modules/tv4/tv4.js:359:14)\n    at ValidatorContext.validateType (/tmp/pm2/node_modules/tv4/tv4.js:751:14)\n    at ValidatorContext.validateBasic (/tmp/pm2/node_modules/tv4/tv4.js:721:19)\n    at ValidatorContext.validateAll (/tmp/pm2/node_modules/tv4/tv4.js:599:19)\n    at ValidatorContext.validateObjectProperties (/tmp/pm2/node_modules/tv4/tv4.js:1010:21)\n    at ValidatorContext.validateObject (/tmp/pm2/node_modules/tv4/tv4.js:961:11)\n    at ValidatorContext.validateAll (/tmp/pm2/node_modules/tv4/tv4.js:603:11)\n    at Object.validate (/tmp/pm2/node_modules/tv4/tv4.js:1573:24)\n    at Object.deployForEnv (/tmp/pm2/node_modules/pm2-deploy/deploy.js:52:12)' }

It's because the host deploy parameter is bad formated ?

vmarchaud commented 6 years ago

As you can see, the problem is the host property, you need to configure it like this : "host": "mydomain:7891"

apoutchika commented 6 years ago

Thank you for you'r fast response !

with the "host": "mydomain:7891" the deploy failed with this error :

ssh: Could not resolve hostname mydomain:5172: Name or service not known

But i have found the good config :

    release: {
      user: 'node8',
      host: 'mydomain.com',
      port: '7891',
      ref: 'origin/release',
      repo: 'git@myrepo.com:myapp.git',
      path: '/home/node8/myapp/',
      'post-deploy': 'npm i && npm run build && pm2 startOrGracefulReload ecosystem.config.js --env production'
    }

It work ! Thank you :-)

phra commented 6 years ago

happy to see this resolved! :smile:

Steveb-p commented 6 years ago

For those who might stumble upon this looking for a way to change ssh port in new pm2:

deploy : {
    production : {
      user : 'node8',
      host : 'mydomain.com',
      ssh_options: [
        'Port=59990',
      ],
      ref  : 'origin/release',
      repo : 'git@myrepo.com:myapp.git',
      path : '/home/node8/myapp',
      'post-deploy' : 'npm i && npm run build && pm2 startOrGreacefulReload ecosystem.config.js --env production'
    }
  }

Might work for you, as it did for me (since port is no longer one of possible parameters).