1

我有一个 Meteor 应用程序,我一直在尝试使用mup-aws-beanstalk 将其部署到 AWS。

这是我的存储库这是一个基本的“Hello world”等价于 MongoDB、Meteor、React、Node.js 应用程序。如何安装

这在本地工作得很好,并在 http://localhost:3000/ 上运行。当我尝试使用 meteor-up mup-aws-beanstalk 插件部署到 AWS 时,它会部署,但我收到 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的错误,有这些行一直重复。我不确定这两个是否相关。 这篇文章描述的问题可能是因为应用程序没有在服务器/端口组合上运行

但是,这篇文章指出这可能是因为 Elastic 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']
};
4

0 回答 0