Unitech / pm2-deploy

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

Deploy fails with error code "0x80070057" #124

Open miparnisari opened 7 years ago

miparnisari commented 7 years ago

I'm trying to deploy a Node application from my Windows 10 machine to a Ubuntu machine hosted in AWS.

See this series of outputs:

C:\Users\miparnisari\Documents\GitHub\app(master)
λ pm2 deploy ecosystem.json5 production
--> Deploying to production environment
--> on host xx.yy.zzz
Error: 0x80070057
Deploy failed

C:\Users\miparnisari\Documents\GitHub\app (master)
λ ssh ubuntu@xx.yy.zzz
Permission denied (publickey).

C:\Users\miparnisari\Documents\GitHub\app (master)
λ ssh -i 'C:/Users/miparnisari/.ssh\aws-eb' ubuntu@xx.yy.zzz
Enter passphrase for key 'C:/Users/miparnisari/.ssh\aws-eb':

It seems as though pm2 is using the wrong key to connect to the target server.

This is my ecosystem.json5 file:


{
  // Applications part
  "apps" : [{
    "name"      : "app",
    "script"    : "app.js",
    // Environment variables injected when starting with --env production
    // http://pm2.keymetrics.io/docs/usage/application-declaration/#switching-to-different-environments
    "env_production" : {
      "NODE_ENV": "production"
    }
  }],
  // Deployment part
  "deploy" : {
    "production" : {
      "user" : "ubuntu",
      "host" : ["xx.yy.zzz"],
      "ref"  : "origin/master",
      "repo" : "git@github.com:miparnisari/app.git",
      // Path of the application on target servers
      "path" : "/var/www/production",
      "key"  : "C:/Users/miparnisari/.ssh/aws-eb.ppk",
      "ssh_options": "StrictHostKeyChecking=no",
      "post-setup": "ls -la",
      "pre-deploy-local" : "echo 'This is a local executed command'",
      "post-deploy" : "npm install && pm2 startOrRestart ecosystem.json --env production",
      "env"  : {
        "PORT": 80,
        "NODE_ENV": "production"
      }
    }
  }
}
vmarchaud commented 7 years ago

Version of windows/pm2/node + are you using the ubuntu inside windows things ?

miparnisari commented 7 years ago

Windows 10. PM2 2.4.0 Ubuntu 14.04.5 LTS

Are there any logs I can enable on PM2 to see what is going on under the hood?

vmarchaud commented 7 years ago

See https://github.com/Microsoft/BashOnWindows/issues/110 and https://github.com/Unitech/pm2/issues/2322 The linux on windows isn't finished and suffer from several issues, pm2 doesn't work at all on it.

miparnisari commented 7 years ago

Ok so maybe the problem was that I was using Cmder, which is a console emulator.

When I use plain ol' CMD, I get this "deploy failed deploy failed" error (also found it in this StackOverflow question)

image

miparnisari commented 7 years ago

Getting somewhere closer now... This is the output with Git Bash:

image

miparnisari commented 7 years ago

Ok I got it to work! Maybe the docs should specify that when using pm2 on windows you need to use Git Bash 😀