部署 Django Web API 到 AWS Elastic Beanstalk 服务器问题

问题描述 投票:0回答:1

我正在尝试在 Elastic Beanstalk 中创建 venv 和应用程序,但遇到了一些错误, 所以还没有完成部署。为了解决这个问题,我尝试将我的 Django 版本从 4.0 降级到 3.2。也对 Python 做了同样的事情。

为了理解和发现问题,我将在这里提供:

  • .ebextensions/django.config
  • my_site/settings.py
  • requirements.txt
  • 服务器部署日志
  • 平台设置

我还使用

python3 manage.py collectstatic
收集了所有静态文件并添加了所有需要的环境变量

django.config

option_settings:
  aws:elasticbeanstalk:container:python:
    WSGIPath: my_site.wsgi:application

settings.py

Django settings for my_site project.
Generated by 'django-admin startproject' using Django 4.1.5.



from pathlib import Path
from os import getenv


BASE_DIR = Path(__file__).resolve().parent.parent



SECRET_KEY = getenv("DJANGOPASS")


DEBUG = getenv("IS_DEVELOPMENT", True)

ALLOWED_HOSTS = [getenv('APP_HOST')]


INSTALLED_APPS = [
    'blog',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'my_site.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [BASE_DIR / 'templates'],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'my_site.wsgi.application'



DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3'
    }
}



AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]




LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_TZ = True



STATIC_ROOT = BASE_DIR / "staticfiles"
STATIC_URL = '/static/'


DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

STATICFILES_DIRS = [
    BASE_DIR / "static"
]

MEDIA_ROOT = BASE_DIR / "uploads"
MEDIA_URL = "/files/"

requirements.txt

asgiref==3.6.0
Django==3.2
gunicorn==20.1.0
Pillow==9.4.0
psycopg2-binary==2.9.5
pytz==2022.7.1
sqlparse==0.4.3

我通过 .zip 上传到 Elastic Beanstalk 的文件

平台设置

Elastic Beanstalk 错误

Mysite-env 日志

    ----------------------------------------
/var/log/web.stdout.log
----------------------------------------
Feb 23 18:51:36 ip-172-31-35-127 web: File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
Feb 23 18:51:36 ip-172-31-35-127 web: File "<frozen importlib._bootstrap>", line 991, in _find_and_load
Feb 23 18:51:36 ip-172-31-35-127 web: File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
Feb 23 18:51:36 ip-172-31-35-127 web: ModuleNotFoundError: No module named 'application'
Feb 23 18:51:36 ip-172-31-35-127 web: [2023-02-23 18:51:36 +0000] [3540] [INFO] Worker exiting (pid: 3540)
Feb 23 18:51:36 ip-172-31-35-127 web: [2023-02-23 18:51:36 +0000] [3530] [INFO] Shutting down: Master
Feb 23 18:51:36 ip-172-31-35-127 web: [2023-02-23 18:51:36 +0000] [3530] [INFO] Reason: Worker failed to boot.
Feb 23 18:51:36 ip-172-31-35-127 web: [2023-02-23 18:51:36 +0000] [3545] [INFO] Starting gunicorn 20.1.0
Feb 23 18:51:36 ip-172-31-35-127 web: [2023-02-23 18:51:36 +0000] [3545] [INFO] Listening at: http://127.0.0.1:8000 (3545)
Feb 23 18:51:36 ip-172-31-35-127 web: [2023-02-23 18:51:36 +0000] [3545] [INFO] Using worker: gthread
Feb 23 18:51:36 ip-172-31-35-127 web: [2023-02-23 18:51:36 +0000] [3551] [INFO] Booting worker with pid: 3551
Feb 23 18:51:36 ip-172-31-35-127 web: [2023-02-23 18:51:36 +0000] [3551] [ERROR] Exception in worker process
Feb 23 18:51:36 ip-172-31-35-127 web: Traceback (most recent call last):
Feb 23 18:51:36 ip-172-31-35-127 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
Feb 23 18:51:36 ip-172-31-35-127 web: worker.init_process()
Feb 23 18:51:36 ip-172-31-35-127 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/workers/gthread.py", line 92, in init_process
Feb 23 18:51:36 ip-172-31-35-127 web: super().init_process()
Feb 23 18:51:36 ip-172-31-35-127 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/workers/base.py", line 134, in init_process
Feb 23 18:51:36 ip-172-31-35-127 web: self.load_wsgi()
Feb 23 18:51:36 ip-172-31-35-127 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
Feb 23 18:51:36 ip-172-31-35-127 web: self.wsgi = self.app.wsgi()
Feb 23 18:51:36 ip-172-31-35-127 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
Feb 23 18:51:36 ip-172-31-35-127 web: self.callable = self.load()
Feb 23 18:51:36 ip-172-31-35-127 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
Feb 23 18:51:36 ip-172-31-35-127 web: return self.load_wsgiapp()
Feb 23 18:51:36 ip-172-31-35-127 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
Feb 23 18:51:36 ip-172-31-35-127 web: return util.import_app(self.app_uri)
Feb 23 18:51:36 ip-172-31-35-127 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/util.py", line 359, in import_app
Feb 23 18:51:36 ip-172-31-35-127 web: mod = importlib.import_module(module)
Feb 23 18:51:36 ip-172-31-35-127 web: File "/usr/lib64/python3.8/importlib/__init__.py", line 127, in import_module
Feb 23 18:51:36 ip-172-31-35-127 web: return _bootstrap._gcd_import(name[level:], package, level)
Feb 23 18:51:36 ip-172-31-35-127 web: File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
Feb 23 18:51:36 ip-172-31-35-127 web: File "<frozen importlib._bootstrap>", line 991, in _find_and_load
Feb 23 18:51:36 ip-172-31-35-127 web: File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
Feb 23 18:51:36 ip-172-31-35-127 web: ModuleNotFoundError: No module named 'application'
Feb 23 18:51:36 ip-172-31-35-127 web: [2023-02-23 18:51:36 +0000] [3551] [INFO] Worker exiting (pid: 3551)
Feb 23 18:51:36 ip-172-31-35-127 web: [2023-02-23 18:51:36 +0000] [3545] [INFO] Shutting down: Master
Feb 23 18:51:36 ip-172-31-35-127 web: [2023-02-23 18:51:36 +0000] [3545] [INFO] Reason: Worker failed to boot.
Feb 23 18:51:37 ip-172-31-35-127 web: [2023-02-23 18:51:37 +0000] [3556] [INFO] Starting gunicorn 20.1.0
Feb 23 18:51:37 ip-172-31-35-127 web: [2023-02-23 18:51:37 +0000] [3556] [INFO] Listening at: http://127.0.0.1:8000 (3556)
Feb 23 18:51:37 ip-172-31-35-127 web: [2023-02-23 18:51:37 +0000] [3556] [INFO] Using worker: gthread
Feb 23 18:51:37 ip-172-31-35-127 web: [2023-02-23 18:51:37 +0000] [3562] [INFO] Booting worker with pid: 3562
Feb 23 18:51:37 ip-172-31-35-127 web: [2023-02-23 18:51:37 +0000] [3562] [ERROR] Exception in worker process
Feb 23 18:51:37 ip-172-31-35-127 web: Traceback (most recent call last):
Feb 23 18:51:37 ip-172-31-35-127 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
Feb 23 18:51:37 ip-172-31-35-127 web: worker.init_process()
Feb 23 18:51:37 ip-172-31-35-127 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/workers/gthread.py", line 92, in init_process
Feb 23 18:51:37 ip-172-31-35-127 web: super().init_process()
Feb 23 18:51:37 ip-172-31-35-127 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/workers/base.py", line 134, in init_process
Feb 23 18:51:37 ip-172-31-35-127 web: self.load_wsgi()
Feb 23 18:51:37 ip-172-31-35-127 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
Feb 23 18:51:37 ip-172-31-35-127 web: self.wsgi = self.app.wsgi()
Feb 23 18:51:37 ip-172-31-35-127 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
Feb 23 18:51:37 ip-172-31-35-127 web: self.callable = self.load()
Feb 23 18:51:37 ip-172-31-35-127 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
Feb 23 18:51:37 ip-172-31-35-127 web: return self.load_wsgiapp()
Feb 23 18:51:37 ip-172-31-35-127 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
Feb 23 18:51:37 ip-172-31-35-127 web: return util.import_app(self.app_uri)
Feb 23 18:51:37 ip-172-31-35-127 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/util.py", line 359, in import_app
Feb 23 18:51:37 ip-172-31-35-127 web: mod = importlib.import_module(module)
Feb 23 18:51:37 ip-172-31-35-127 web: File "/usr/lib64/python3.8/importlib/__init__.py", line 127, in import_module
Feb 23 18:51:37 ip-172-31-35-127 web: return _bootstrap._gcd_import(name[level:], package, level)
Feb 23 18:51:37 ip-172-31-35-127 web: File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
Feb 23 18:51:37 ip-172-31-35-127 web: File "<frozen importlib._bootstrap>", line 991, in _find_and_load
Feb 23 18:51:37 ip-172-31-35-127 web: File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
Feb 23 18:51:37 ip-172-31-35-127 web: ModuleNotFoundError: No module named 'application'
Feb 23 18:51:37 ip-172-31-35-127 web: [2023-02-23 18:51:37 +0000] [3562] [INFO] Worker exiting (pid: 3562)
Feb 23 18:51:37 ip-172-31-35-127 web: [2023-02-23 18:51:37 +0000] [3556] [INFO] Shutting down: Master
Feb 23 18:51:37 ip-172-31-35-127 web: [2023-02-23 18:51:37 +0000] [3556] [INFO] Reason: Worker failed to boot.
Feb 23 18:51:37 ip-172-31-35-127 web: [2023-02-23 18:51:37 +0000] [3567] [INFO] Starting gunicorn 20.1.0
Feb 23 18:51:37 ip-172-31-35-127 web: [2023-02-23 18:51:37 +0000] [3567] [INFO] Listening at: http://127.0.0.1:8000 (3567)
Feb 23 18:51:37 ip-172-31-35-127 web: [2023-02-23 18:51:37 +0000] [3567] [INFO] Using worker: gthread
Feb 23 18:51:37 ip-172-31-35-127 web: [2023-02-23 18:51:37 +0000] [3573] [INFO] Booting worker with pid: 3573
Feb 23 18:51:37 ip-172-31-35-127 web: [2023-02-23 18:51:37 +0000] [3573] [ERROR] Exception in worker process
Feb 23 18:51:37 ip-172-31-35-127 web: Traceback (most recent call last):
Feb 23 18:51:37 ip-172-31-35-127 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
Feb 23 18:51:37 ip-172-31-35-127 web: worker.init_process()
Feb 23 18:51:37 ip-172-31-35-127 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/workers/gthread.py", line 92, in init_process
Feb 23 18:51:37 ip-172-31-35-127 web: super().init_process()
Feb 23 18:51:37 ip-172-31-35-127 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/workers/base.py", line 134, in init_process
Feb 23 18:51:37 ip-172-31-35-127 web: self.load_wsgi()
Feb 23 18:51:37 ip-172-31-35-127 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
Feb 23 18:51:37 ip-172-31-35-127 web: self.wsgi = self.app.wsgi()
Feb 23 18:51:37 ip-172-31-35-127 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
Feb 23 18:51:37 ip-172-31-35-127 web: self.callable = self.load()
Feb 23 18:51:37 ip-172-31-35-127 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
Feb 23 18:51:37 ip-172-31-35-127 web: return self.load_wsgiapp()
Feb 23 18:51:37 ip-172-31-35-127 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
Feb 23 18:51:37 ip-172-31-35-127 web: return util.import_app(self.app_uri)
Feb 23 18:51:37 ip-172-31-35-127 web: File "/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/gunicorn/util.py", line 359, in import_app
Feb 23 18:51:37 ip-172-31-35-127 web: mod = importlib.import_module(module)
Feb 23 18:51:37 ip-172-31-35-127 web: File "/usr/lib64/python3.8/importlib/__init__.py", line 127, in import_module
Feb 23 18:51:37 ip-172-31-35-127 web: return _bootstrap._gcd_import(name[level:], package, level)
Feb 23 18:51:37 ip-172-31-35-127 web: File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
Feb 23 18:51:37 ip-172-31-35-127 web: File "<frozen importlib._bootstrap>", line 991, in _find_and_load
Feb 23 18:51:37 ip-172-31-35-127 web: File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
Feb 23 18:51:37 ip-172-31-35-127 web: ModuleNotFoundError: No module named 'application'
Feb 23 18:51:37 ip-172-31-35-127 web: [2023-02-23 18:51:37 +0000] [3573] [INFO] Worker exiting (pid: 3573)
Feb 23 18:51:37 ip-172-31-35-127 web: [2023-02-23 18:51:37 +0000] [3567] [INFO] Shutting down: Master
Feb 23 18:51:37 ip-172-31-35-127 web: [2023-02-23 18:51:37 +0000] [3567] [INFO] Reason: Worker failed to boot.


----------------------------------------
/var/log/eb-engine.log
----------------------------------------
2023/02/23 18:51:32.560762 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-get-metadata -s arn:aws:cloudformation:eu-west-3:243314602867:stack/awseb-e-dz5hnpcdmt-stack/bdbf3370-b3aa-11ed-8674-0eb63367dab0 -r AWSEBBeanstalkMetadata --region eu-west-3
2023/02/23 18:51:32.956373 [INFO] Generating rsyslog config from Procfile
2023/02/23 18:51:32.957822 [INFO] Running command /bin/sh -c systemctl restart rsyslog.service
2023/02/23 18:51:32.974541 [INFO] Executing instruction: PostBuildEbExtension
2023/02/23 18:51:32.974564 [INFO] Starting executing the config set Infra-EmbeddedPostBuild.
2023/02/23 18:51:32.974577 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-init -s arn:aws:cloudformation:eu-west-3:243314602867:stack/awseb-e-dz5hnpcdmt-stack/bdbf3370-b3aa-11ed-8674-0eb63367dab0 -r AWSEBAutoScalingGroup --region eu-west-3 --configsets Infra-EmbeddedPostBuild
2023/02/23 18:51:33.369337 [INFO] Finished executing the config set Infra-EmbeddedPostBuild.

2023/02/23 18:51:33.369371 [INFO] Executing instruction: CleanEbExtensions
2023/02/23 18:51:33.369481 [INFO] Cleaned ebextensions subdirectories from app staging directory.
2023/02/23 18:51:33.369487 [INFO] Executing instruction: RunAppDeployPreDeployHooks
2023/02/23 18:51:33.369497 [INFO] Executing platform hooks in .platform/hooks/predeploy/
2023/02/23 18:51:33.369513 [INFO] The dir .platform/hooks/predeploy/ does not exist
2023/02/23 18:51:33.369517 [INFO] Finished running scripts in /var/app/staging/.platform/hooks/predeploy
2023/02/23 18:51:33.369522 [INFO] Executing instruction: stop X-Ray
2023/02/23 18:51:33.369538 [INFO] stop X-Ray ...
2023/02/23 18:51:33.369554 [INFO] Running command /bin/sh -c systemctl show -p PartOf xray.service
2023/02/23 18:51:33.376859 [WARN] stopProcess Warning: process xray is not registered 
2023/02/23 18:51:33.376875 [INFO] Running command /bin/sh -c systemctl stop xray.service
2023/02/23 18:51:33.384591 [INFO] Executing instruction: stop proxy
2023/02/23 18:51:33.384607 [INFO] Running command /bin/sh -c systemctl show -p PartOf httpd.service
2023/02/23 18:51:33.489467 [WARN] deregisterProcess Warning: process httpd is not registered, skipping...

2023/02/23 18:51:33.489495 [INFO] Running command /bin/sh -c systemctl show -p PartOf nginx.service
2023/02/23 18:51:33.496143 [WARN] deregisterProcess Warning: process nginx is not registered, skipping...

2023/02/23 18:51:33.496156 [INFO] Executing instruction: FlipApplication
2023/02/23 18:51:33.496161 [INFO] Fetching environment variables...
2023/02/23 18:51:33.496280 [INFO] Purge old process...
2023/02/23 18:51:33.496294 [INFO] Removing /var/app/current/ if it exists
2023/02/23 18:51:33.496304 [INFO] Renaming /var/app/staging/ to /var/app/current/
2023/02/23 18:51:33.496321 [INFO] Register application processes...
2023/02/23 18:51:33.496325 [INFO] Registering the proc: web

2023/02/23 18:51:33.496347 [INFO] Running command /bin/sh -c systemctl show -p PartOf web.service
2023/02/23 18:51:33.502814 [INFO] Running command /bin/sh -c systemctl daemon-reload
2023/02/23 18:51:33.609809 [INFO] Running command /bin/sh -c systemctl reset-failed
2023/02/23 18:51:33.614039 [INFO] Running command /bin/sh -c systemctl is-enabled eb-app.target
2023/02/23 18:51:33.617661 [INFO] Copying file /opt/elasticbeanstalk/config/private/aws-eb.target to /etc/systemd/system/eb-app.target
2023/02/23 18:51:33.619404 [INFO] Running command /bin/sh -c systemctl enable eb-app.target
2023/02/23 18:51:33.738151 [INFO] Created symlink from /etc/systemd/system/multi-user.target.wants/eb-app.target to /etc/systemd/system/eb-app.target.

2023/02/23 18:51:33.738181 [INFO] Running command /bin/sh -c systemctl start eb-app.target
2023/02/23 18:51:33.744208 [INFO] Running command /bin/sh -c systemctl enable web.service
2023/02/23 18:51:33.878678 [INFO] Created symlink from /etc/systemd/system/multi-user.target.wants/web.service to /etc/systemd/system/web.service.

2023/02/23 18:51:33.878710 [INFO] Running command /bin/sh -c systemctl show -p PartOf web.service
2023/02/23 18:51:33.884238 [INFO] Running command /bin/sh -c systemctl is-active web.service
2023/02/23 18:51:33.890912 [INFO] Running command /bin/sh -c systemctl start web.service
2023/02/23 18:51:33.914481 [INFO] Executing instruction: start X-Ray
2023/02/23 18:51:33.914496 [INFO] X-Ray is not enabled.
2023/02/23 18:51:33.914501 [INFO] Executing instruction: start proxy with new configuration
2023/02/23 18:51:33.914519 [INFO] Running command /bin/sh -c /usr/sbin/nginx -t -c /var/proxy/staging/nginx/nginx.conf
2023/02/23 18:51:34.555617 [INFO] nginx: the configuration file /var/proxy/staging/nginx/nginx.conf syntax is ok
nginx: configuration file /var/proxy/staging/nginx/nginx.conf test is successful

2023/02/23 18:51:34.555694 [INFO] Running command /bin/sh -c cp -rp /var/proxy/staging/nginx/* /etc/nginx
2023/02/23 18:51:34.575052 [INFO] Running command /bin/sh -c systemctl show -p PartOf nginx.service
2023/02/23 18:51:34.586649 [INFO] Running command /bin/sh -c systemctl daemon-reload
2023/02/23 18:51:34.697962 [INFO] Running command /bin/sh -c systemctl reset-failed
2023/02/23 18:51:34.709390 [INFO] Running command /bin/sh -c systemctl show -p PartOf nginx.service
2023/02/23 18:51:34.718835 [INFO] Running command /bin/sh -c systemctl is-active nginx.service
2023/02/23 18:51:34.726724 [INFO] Running command /bin/sh -c systemctl start nginx.service
2023/02/23 18:51:34.779955 [INFO] Executing instruction: configureSqsd
2023/02/23 18:51:34.779971 [INFO] This is a web server environment instance, skip configure sqsd daemon ...
2023/02/23 18:51:34.779976 [INFO] Executing instruction: startSqsd
2023/02/23 18:51:34.779979 [INFO] This is a web server environment instance, skip start sqsd daemon ...
2023/02/23 18:51:34.779983 [INFO] Executing instruction: Track pids in healthd
2023/02/23 18:51:34.779988 [INFO] This is an enhanced health env...
2023/02/23 18:51:34.780002 [INFO] Running command /bin/sh -c systemctl show -p ConsistsOf aws-eb.target | cut -d= -f2
2023/02/23 18:51:34.786765 [INFO] healthd.service cfn-hup.service nginx.service

2023/02/23 18:51:34.786783 [INFO] Running command /bin/sh -c systemctl show -p ConsistsOf eb-app.target | cut -d= -f2
2023/02/23 18:51:34.791538 [INFO] web.service

2023/02/23 18:51:34.791581 [WARN] Failed to read file /var/pids/web.pid, retry attempt: 1
2023/02/23 18:51:35.791763 [INFO] Executing instruction: RunAppDeployPostDeployHooks
2023/02/23 18:51:35.791786 [INFO] Executing platform hooks in .platform/hooks/postdeploy/
2023/02/23 18:51:35.791804 [INFO] The dir .platform/hooks/postdeploy/ does not exist
2023/02/23 18:51:35.791808 [INFO] Finished running scripts in /var/app/current/.platform/hooks/postdeploy
2023/02/23 18:51:35.791815 [INFO] Executing cleanup logic
2023/02/23 18:51:35.791917 [INFO] CommandService Response: {"status":"SUCCESS","api_version":"1.0","results":[{"status":"SUCCESS","msg":"Engine execution has succeeded.","returncode":0,"events":[{"msg":"Instance deployment successfully generated a 'Procfile'.","timestamp":1677178291763,"severity":"INFO"},{"msg":"Instance deployment completed successfully.","timestamp":1677178295791,"severity":"INFO"}]}]}

2023/02/23 18:51:35.792057 [INFO] Platform Engine finished execution on command: app-deploy

2023/02/23 18:53:15.947776 [INFO] Starting...
2023/02/23 18:53:15.947819 [INFO] Starting EBPlatform-PlatformEngine
2023/02/23 18:53:15.947837 [INFO] reading event message file
2023/02/23 18:53:15.947971 [INFO] Engine received EB command cfn-hup-exec

2023/02/23 18:53:16.028426 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-get-metadata -s arn:aws:cloudformation:eu-west-3:243314602867:stack/awseb-e-dz5hnpcdmt-stack/bdbf3370-b3aa-11ed-8674-0eb63367dab0 -r AWSEBAutoScalingGroup --region eu-west-3
2023/02/23 18:53:16.342021 [INFO] Running command /bin/sh -c /opt/aws/bin/cfn-get-metadata -s arn:aws:cloudformation:eu-west-3:243314602867:stack/awseb-e-dz5hnpcdmt-stack/bdbf3370-b3aa-11ed-8674-0eb63367dab0 -r AWSEBBeanstalkMetadata --region eu-west-3
2023/02/23 18:53:16.647728 [INFO] checking whether command tail-log is applicable to this instance...
2023/02/23 18:53:16.647746 [INFO] this command is applicable to the instance, thus instance should execute command
2023/02/23 18:53:16.647750 [INFO] Engine command: (tail-log)

2023/02/23 18:53:16.647800 [INFO] Executing instruction: GetTailLogs
2023/02/23 18:53:16.647806 [INFO] Tail Logs...
2023/02/23 18:53:16.648099 [INFO] Running command /bin/sh -c tail -n 100 /var/log/web.stdout.log
2023/02/23 18:53:16.649944 [INFO] Running command /bin/sh -c tail -n 100 /var/log/eb-engine.log


----------------------------------------
/var/log/eb-hooks.log
----------------------------------------


----------------------------------------
/var/log/nginx/access.log
----------------------------------------


----------------------------------------
/var/log/nginx/error.log
----------------------------------------
python django amazon-web-services amazon-elastic-beanstalk
1个回答
0
投票

我遇到了同样的问题。如果您关注将 Django 应用程序部署到 Elastic Beanstalk 文章,在创建 .ebextentions 文件夹后,请确保您在运行时位于 django 项目目录中,而不是在 .ebextentions 文件夹中

eb init

运行时

eb init -p python-3.7 django-tutorial
你当前的目录应该是这样的: '~/我的网站/'

代替: '~/my_site/.ebextentions/'

© www.soinside.com 2019 - 2024. All rights reserved.