Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python EBS容器命令:django管理工作目录错误?_Python_Django_Django Admin_Amazon Elastic Beanstalk - Fatal编程技术网

Python EBS容器命令:django管理工作目录错误?

Python EBS容器命令:django管理工作目录错误?,python,django,django-admin,amazon-elastic-beanstalk,Python,Django,Django Admin,Amazon Elastic Beanstalk,我有一个相当简单的django应用程序,部署在elastic beanstalk环境中。我已经为部署过程创建了许多定制,包括容器命令中的经典“collectstatic”脚本。以下是我的配置的一部分: container_commands: 01_replace_wsgi_config: command: cp .ebextensions/wsgi.conf /opt/python/ondeck/wsgi.conf 02_collect_static:

我有一个相当简单的django应用程序,部署在elastic beanstalk环境中。我已经为部署过程创建了许多定制,包括容器命令中的经典“collectstatic”脚本。以下是我的配置的一部分:

container_commands:
    01_replace_wsgi_config:
        command: cp .ebextensions/wsgi.conf /opt/python/ondeck/wsgi.conf
    02_collect_static:
        command: django-admin.py collectstatic --noinput
如您所见,我使用ondeck文件夹自定义wsgi.conf文件,因为自动生成的文件对我来说不够好

现在,我偶然发现的问题是,上面的django-admin.py调用正在旧的“current”目录上运行,一旦“ondeck”目录变为“current”,其结果就不可见了,显然,这是在执行
container\u命令之后发生的。对于来自django安装的应用程序的javascript文件,这看起来像404。我是通过观察/var/log/eb-actions.log输出来发现这一点的:

  ...
  Copying '/opt/python/run/venv/local/lib/python2.7/site-packages/jquery/static/js/jquery.js'
  Copying '/opt/python/run/venv/local/lib/python2.7/site-packages/django_ajax/static/django_ajax/js/jquery.ajax.min.js'
  Copying '/opt/python/run/venv/local/lib/python2.7/site-packages/django_ajax/static/django_ajax/js/jquery.ajax-plugin.js'
  Copying '/opt/python/run/venv/local/lib/python2.7/site-packages/django_ajax/static/django_ajax/js/jquery.ajax.js'
  Copying '/opt/python/run/venv/local/lib/python2.7/site-packages/django_ajax/static/django_ajax/js/jquery.ajax-plugin.min.js'

  0 static files copied to '/opt/python/current/app/dashboard/dashboard/static', 74 unmodified.
我找到了一个对我有好处的解决方案:

02_collect_static:
    command: python dashboard/manage.py collectstatic --noinput
此命令确保collectstatic在即将变为“当前”的“ondeck”forder上运行:

让我担心的是,我不得不改变一些本来应该按照规则运作的东西

我怀疑我的问题可能隐藏在这里(app.config):

PYTHONPATH设置为“current”,这可能会在处理container_命令时强制django-admin.py在那里查看,而不是“ondeck”。
如果是这样的话,对于一个正确的经典部署来说,这个设置应该是什么样子?我采用了这种格式…

我在许多项目中使用过这种格式,效果非常好

02_collectstatic:
  command: "source /opt/python/run/venv/bin/activate && python manage.py collectstatic --noinput"

选项设置看起来不错。

我已经在许多项目中使用过它,效果非常好

02_collectstatic:
  command: "source /opt/python/run/venv/bin/activate && python manage.py collectstatic --noinput"

选项设置看起来不错。

您最终是如何解决的?您最终是如何解决的?
02_collectstatic:
  command: "source /opt/python/run/venv/bin/activate && python manage.py collectstatic --noinput"