502 Bad Gateway при размещении приложения Meteor на AWS Elasti c Beanstalk с Meteor-up - PullRequest
0 голосов
/ 13 июля 2020

У меня есть приложение Meteor, которое я пытался развернуть на AWS с mup- aws -beanstalk.

Вот мой репозиторий Это базовый c "Hello world" эквивалент приложения MongoDB, Meteor, React, Node.js. Как установить

Это прекрасно работает локально и работает на http://localhost: 3000 /. Когда я пытаюсь выполнить развертывание на AWS с помощью плагина meteor-up mup- aws -beanstalk, он развертывается, но я получаю ошибку 502 Bad Gateway.

Я новичок в этом, но я провел некоторое исследование и проверил журналы.

Проверяя журналы, я вижу, что стартовый скрипт не работает должным образом

> mup-meteor-example-deploy-aws@1.0.0 start /var/app/current
> bash ./start.sh


┌──────────────────────────────────────────────────┐
│             npm update check failed              │
│       Try running with sudo or get access        │
│       to the local update config store via       │
│ sudo chown -R $USER:$(id -gn $USER) /tmp/.config │
└──────────────────────────────────────────────────┘

┌──────────────────────────────────────────────────┐
│             npm update check failed              │
│       Try running with sudo or get access        │
│       to the local update config store via       │
│ sudo chown -R $USER:$(id -gn $USER) /tmp/.config │
└──────────────────────────────────────────────────┘
Node version
v12.16.1
Npm version
6.14.0
=> Starting health check server
=> Starting App
/var/app/current/programs/server/node_modules/fibers/fibers.js:90
                    return fn.apply(this, arguments);
                              ^

Error: $ROOT_URL, if specified, must be an URL
    at packages/meteor.js:1328:13
    at packages/meteor.js:1343:4
    at packages/meteor.js:1508:3
    at /var/app/current/programs/server/boot.js:401:38
    at Array.forEach (<anonymous>)
    at /var/app/current/programs/server/boot.js:226:21
    at /var/app/current/programs/server/boot.js:464:7
    at Function.run (/var/app/current/programs/server/profile.js:280:14)
    at /var/app/current/programs/server/boot.js:463:13
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mup-meteor-example-deploy-aws@1.0.0 start: `bash ./start.sh`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the mup-meteor-example-deploy-aws@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

Я проверил указанную выше проблему и другие вопросы StackOverflow, чтобы указать URL начните с http или https, что и делает мой.

Тогда также есть ошибка от nginx, есть эти строки, которые повторяются. Я не уверен, связаны ли эти двое. В этом сообщении описывается, что проблема может быть связана с тем, что приложение не запущено на комбинации сервер / порт.

ОДНАКО, в этом сообщении говорится, что это может быть из-за Elasti c Beanstalk сначала читает неправильный файл и, следовательно, не открывает порты в первую очередь?

Я не уверен, как и где изменить номера портов, или это проблема с npm.

-------------------------------------
/var/log/nginx/error.log
-------------------------------------
2020/07/13 04:02:02 [error] 4632#0: *148508 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.21.16, server: , request: "GET /aws-health-check-3984729847289743128904723 HTTP/1.1", upstream: "http://127.0.0.1:8039/aws-health-check-3984729847289743128904723", host: "172.31.46.135"
2020/07/13 04:02:06 [error] 4632#0: *148510 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.46.174, server: , request: "GET /aws-health-check-3984729847289743128904723 HTTP/1.1", upstream: "http://127.0.0.1:8039/aws-health-check-3984729847289743128904723", host: "172.31.46.135"
2020/07/13 04:02:17 [error] 4632#0: *148512 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.21.16, server: , request: "GET /aws-health-check-3984729847289743128904723 HTTP/1.1", upstream: "http://127.0.0.1:8039/aws-health-check-3984729847289743128904723", host: "172.31.46.135"

Это мой вывод развертывания

PS G:\GitFolder\meteor-example-deploy-aws\.deploy> mup deploy
=> Setting up
=> Ensuring IAM Roles and Instance Profiles are setup
Building App Bundle Locally

WARNING: The output directory is under your source tree.
         Your generated files may get interpreted as source code!
         Consider building into a different directory instead
         meteor build ../output

app/node_modules/semantic-ui-css/semantic.css: warn: There are some @import rules in the middle of a file. This might be a bug, as imports are only valid at the beginning of a file.
Browserslist: caniuse-lite is outdated. Please run next command `npm update`

Unable to resolve some modules:

  "@babel/runtime/helpers/createSuper" in /G/GitFolder/meteor-example-deploy-aws/app/imports/ui/layouts/App.jsx (web.browser.legacy)

If you notice problems related to these missing modules, consider running:

  meteor npm install --save @babel/runtime

=> Archiving Bundle
  10% Archived
  20% Archived
  30% Archived
  40% Archived
  50% Archived
  60% Archived
  70% Archived
  80% Archived
  90% Archived
  100% Archived
=> Uploading bundle
  Uploaded 11%
  Uploaded 23%
  Uploaded 35%
  Uploaded 46%
  Uploaded 58%
  Uploaded 70%
  Uploaded 81%
  Uploaded 93%
  Uploaded 100%
  Finishing upload. This could take a couple minutes
=> Creating Version
=> Configuring Beanstalk Environment
  Updated Environment
=> Waiting for Beanstalk Environment to finish updating
  Env Event: Updating environment mup-env-meteor-example-deploy-aws's configuration settings.
  Env Event: Rolling with Additional Batch deployment policy enabled. Launching  a new batch of 1 additional instance(s).
  Env Event: Batch 1: 1 EC2 instance(s) [i-0b017a1b7f1c7151a] launched. Deploying application version.
  Env Event: Environment health has transitioned from Severe to Degraded. 100.0 % of the requests are failing with HTTP 5xx. ELB processes are not healthy on 1 out of 2 instances. Configuration update in progress on 1 instance. 0 out of 2 instances completed (running for 2 minutes). ELB health is failing or not available for 1 out of 2 instances. Impaired services on 1 out of 2 instances.
  Env Event: Added instance [i-0b017a1b7f1c7151a] to your environment.
  Env Event: Failed to run npm install. Snapshot logs for more details.
  Env Event: Retrieving logs prior to instance(s) termination. Logs will be available for an hour in the environment management console and at elasticbeanstalk-us-east-1-966889535256/resources/environments/logs/bundle/e-kvnxyajrem.
  Env Event: During an aborted deployment, some instances may have deployed the new application version. To ensure all instances are running the same version, re-deploy the appropriate application version.
  Env Event: Failed to deploy configuration.
  Env Event: Terminating excess instance(s): [i-0b017a1b7f1c7151a].
  Env Event: Command execution completed on all instances successfully.
  Env Event: [Instance: i-0b017a1b7f1c7151a] Successfully finished bundling 16 log(s)
=> Deploying new version
=> Waiting for Beanstalk Environment to finish updating
  Env Event: Environment health has transitioned from Degraded to Severe. 100.0 % of the requests are failing with HTTP 5xx. Command failed on 1 out of 2 instances. Incorrect application version found on 1 out of 2 instances. Expected version "5" (deployment 10). ELB processes are not healthy on all instances. Application update in progress (running for 42 seconds). ELB health is failing or not available for all instances. Impaired services on 1 out of 2 instances.
  Env Event: Rolling with Additional Batch deployment policy enabled. Launching  a new batch of 1 additional instance(s).
  Env Event: Removed instance [i-0b017a1b7f1c7151a] from your environment.
  Env Event: Added instance [i-0733205831e115a28] to your environment.
  Env Event: Batch 1: 1 EC2 instance(s) [i-0733205831e115a28] launched. Deploying application version '5'.
  Env Event: Unsuccessful command execution on instance id(s) 'i-0733205831e115a28'. Aborting the operation.
  Env Event: Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
  Env Event: [Instance: i-0733205831e115a28] Command failed on instance. Return code: 127 Output: (TRUNCATED)...
/opt/elasticbeanstalk/hooks/appdeploy/pre/45node.sh: line 12: nvm: command not found
/opt/elasticbeanstalk/hooks/appdeploy/pre/45node.sh: line 13: nvm: command not found
/opt/elasticbeanstalk/hooks/appdeploy/pre/45node.sh: line 14: npm: command not found.
Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/45node.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
  Env Event: Retrieving logs prior to instance(s) termination. Logs will be available for an hour in the environment management console and at elasticbeanstalk-us-east-1-966889535256/resources/environments/logs/bundle/e-kvnxyajrem.
  Env Event: Excess instance(s) terminated.
  Env Event: Terminating excess instance(s): [i-0733205831e115a28].
  Env Event: Command execution completed on all instances successfully.
  Env Event: [Instance: i-0733205831e115a28] Successfully finished bundling 15 log(s)
  Env Event: Environment health has transitioned from Severe to Degraded. 100.0 % of the requests are failing with HTTP 5xx. Command failed on 1 out of 2 instances. Incorrect application version found on 1 out of 2 instances. Expected version "1" (deployment 1). ELB processes are not healthy on 1 out of 2 instances. Application update is aborting. 1 out of 2 instances completed (running for 4 minutes). ELB health is failing or not available for 1 out of 2 instances. Impaired services on 1 out of 2 instances.
App is running at mup-env-meteor-example-deploy-aws.eba-cah6ppkm.us-east-1.elasticbeanstalk.com
=> Finding old versions
=> Removing old versions
=> Updating Beanstalk SSL Config

и все это в моем mup. js файл

  app: {
    // Tells mup that the AWS Beanstalk plugin will manage the app
    type: 'aws-beanstalk',
    name: 'meteor-example-deploy-aws',
    path: 'G:/GitFolder/meteor-example-deploy-aws/app',
    env: {
      ROOT_URL: 'http://mup-env-meteor-example-deploy-aws.eba-cah6ppkm.us-east-1.elasticbeanstalk.com/',
      MONGO_URL: 'mongodb://MYUSERNAME:MYPASSREDACTED@docdb-2020-07-06-07-57-38.cluster-c9vs8fwnppko.us-east-1.docdb.amazonaws.com:27017/?ssl=true&ssl_ca_certs=rds-combined-ca-bundle.pem&replicaSet=rs0&readPreference=secondaryPreferred&retryWrites=false'
    },
    auth: {
      id: 'AKIA6C...',
      secret: 'xCBpL....'
    },
    minInstances: 1
  },
  plugins: ['mup-aws-beanstalk']
};
...