Почему я получаю эту ошибку при загрузке приложения Flask в Elasti c Beanstalk на AWS? - PullRequest
0 голосов
/ 23 апреля 2020

Я пытаюсь загрузить свое приложение службы Flask REST в AWS Elasti c Beanstalk (впервые), и когда я eb create, я получаю следующий вывод:

Creating application version archive "app-ef62-200423_114608".
Uploading crunchtime/app-ef62-200423_114608.zip to S3. This may take a while.
Upload Complete.
Environment details for: crunchtime-dev2
  Application name: crunchtime
  Region: us-east-1
  Deployed Version: app-ef62-200423_114608
  Environment ID: e-tmnvmkbmbm
  Platform: arn:aws:elasticbeanstalk:us-east-1::platform/Python 3.7 running on 64bit Amazon Linux 2/3.0.0
  Tier: WebServer-Standard-1.0
  CNAME: crunchtime-dev2.us-east-1.elasticbeanstalk.com
  Updated: 2020-04-23 16:46:12.577000+00:00
Printing Status:
2020-04-23 16:46:11    INFO    createEnvironment is starting.
2020-04-23 16:46:12    INFO    Using elasticbeanstalk-us-east-1-046059243220 as Amazon S3 storage bucket for environment data.
2020-04-23 16:46:34    INFO    Created target group named: arn:aws:elasticloadbalancing:us-east-1:046059243220:targetgroup/awseb-AWSEB-1MA4IAAU8730S/44d40acdd42fb6fa
2020-04-23 16:46:34    INFO    Created security group named: sg-050734e1b49a45778
2020-04-23 16:46:49    INFO    Created security group named: awseb-e-tmnvmkbmbm-stack-AWSEBSecurityGroup-BNLNN14GCIVO
2020-04-23 16:46:49    INFO    Created Auto Scaling launch configuration named: awseb-e-tmnvmkbmbm-stack-AWSEBAutoScalingLaunchConfiguration-17QIO7WCEKLK
2020-04-23 16:47:51    INFO    Created Auto Scaling group named: awseb-e-tmnvmkbmbm-stack-AWSEBAutoScalingGroup-1AUHYUG14UP16
2020-04-23 16:47:51    INFO    Waiting for EC2 instances to launch. This may take a few minutes.
2020-04-23 16:48:06    INFO    Created Auto Scaling group policy named: arn:aws:autoscaling:us-east-1:046059243220:scalingPolicy:c87fb50f-412c-48be-8b86-3fdb0c5941cc:autoScalingGroupName/awseb-e-tmnvmkbmbm-stack-AWSEBAutoScalingGroup-1AUHYUG14UP16:policyName/awseb-e-tmnvmkbmbm-stack-AWSEBAutoScalingScaleUpPolicy-4ZFDFHPU2G5H
2020-04-23 16:48:07    INFO    Created Auto Scaling group policy named: arn:aws:autoscaling:us-east-1:046059243220:scalingPolicy:b989a6ea-e4da-4b72-ae95-d63d045d4e70:autoScalingGroupName/awseb-e-tmnvmkbmbm-stack-AWSEBAutoScalingGroup-1AUHYUG14UP16:policyName/awseb-e-tmnvmkbmbm-stack-AWSEBAutoScalingScaleDownPolicy-ZX79COIXDDM8
2020-04-23 16:48:07    INFO    Created CloudWatch alarm named: awseb-e-tmnvmkbmbm-stack-AWSEBCloudwatchAlarmHigh-1AYVN9U2HYR6B
2020-04-23 16:48:07    INFO    Created CloudWatch alarm named: awseb-e-tmnvmkbmbm-stack-AWSEBCloudwatchAlarmLow-NFZ51TH8BXXG
2020-04-23 16:49:41    INFO    Created load balancer named: arn:aws:elasticloadbalancing:us-east-1:046059243220:loadbalancer/app/awseb-AWSEB-1WW6C7M7P6W7Y/bbd89b5ee56cefb5
2020-04-23 16:49:57    INFO    Created Load Balancer listener named: arn:aws:elasticloadbalancing:us-east-1:046059243220:listener/app/awseb-AWSEB-1WW6C7M7P6W7Y/bbd89b5ee56cefb5/4cf5978d2b57402f
**2020-04-23 16:50:59    ERROR   [Instance: i-013f4f7a5ee8b4c9b] Command failed on instance. An unexpected error has occurred [ErrorCode: 0000000001].**
2020-04-23 16:50:59    INFO    Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
**2020-04-23 16:52:03    ERROR   Create environment operation is complete, but with errors. For more information, see troubleshooting documentation.**

ERROR: ServiceError - Create environment operation is complete, but with errors. For more information, see troubleshooting documentation.

eb health дает мне следующий вывод:

WebServer                                                                                                   Python 3.7 running on 64bit Amazon Linux 2/3.0.0  total      ok    warning  degraded  severe    info   pending  unknown 
    1        0        0        0        1        0        0        0    

  instance-id           status     cause                                                                                                            health  
    Overall             Severe     Command failed on all instances.                                                                                                                            Incorrect application version found on all instances. Expected version "app-ef62-200423_014023" (deployment 1).                                             ELB processes are not healthy on all instances.                                                                                                             ELB health is failing or not available for all instances.                                                                  i-07fcd462c512ebd70   Severe     Application deployment failed at 2020-04-23T06:49:51Z with exit status 1 and error: Engine execution has encountered an e                                   Incorrect application version "app-ef62-200423_014904" (deployment 2). Expected version "app-ef62-200423_014023" (deploym                                   Process default has been unhealthy for 10 hours (Target.ResponseCodeMismatch).                                              

и eb status --verbose дает следующее:

Environment details for: crunchtime-dev
  Application name: crunchtime
  Region: us-east-1
  Deployed Version: app-ef62-200423_014023
  Environment ID: e-pxhhwgvphn
  Platform: arn:aws:elasticbeanstalk:us-east-1::platform/Python 3.7 running on 64bit Amazon Linux 2/3.0.0
  Tier: WebServer-Standard-1.0
  CNAME: crunchtime-dev.us-east-1.elasticbeanstalk.com
  Updated: 2020-04-23 06:49:55.463000+00:00
  Status: Ready
  Health: Red
  Running instances: 1
           i-07fcd462c512ebd70: unhealthy
                Description: Health checks failed with these codes: [502]
                Reason: Target.ResponseCodeMismatch

Сначала я использую Pipenv для этого приложения Я думал, что это потому, что я использовал этот Pip-файл, а не файл require.txt, но эта статья, кажется, указывает, что я могу использовать Pipenv, пока я использую Amazon Linux 2, которым я и являюсь. (Python 3.7 работает на 64-битной Amazon Linux 2)

Вот содержимое моего Pipfile:

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
pylint = "*"
flake8 = "*"
autopep8 = "*"
rope = "*"

[packages]
flask = "*"
flask-restful = "*"
marshmallow = "*"
flask-marshmallow = "*"
flask-sqlalchemy = "*"
marshmallow-sqlalchemy = "*"
flask-migrate = "*"
flask-script = "*"
psycopg2-binary = "*"
python-dotenv = "*"
bcrypt = "*"
pyjwt = "*"
flask-cors = "*"
exponent-server-sdk = "*"
flask-apscheduler = "*"

[requires]
python_version = "3.7"

[scripts]
dev = "python application.py"
initdb = "python migrate.py db init"
migrate = "python migrate.py db migrate"
upgrade = "python migrate.py db upgrade"
downgrade = "python migrate.py db downgrade"
...