我已经将我的Django项目部署到AWS上的EB上,它工作得很好。
我现在尝试使用一个不可变的部署策略来部署它,但是我得到了这个错误:
Command failed on instance. Return code: 2 Output: python: can't open file '/opt/python/current/app/manage.py': [Errno pt/python/current/app/manage.py': [Errno 2] No such file or directory.
这会在命令执行过程中发生:source /opt/python/current/env && python /opt/python/current/app/manage.py migrate
由于某些原因,我不能在第一次部署时包含该命令。
有人知道如何在Django中使用不可变的部署方法吗?
发布于 2020-07-17 16:16:20
以下内容:
source /opt/python/current/env && python /opt/python/current/app/manage.py migrate当您通过ssh进入EB实例并希望使用环境变量手动运行代码时,它非常有用。
在我看来,在部署EB时,在.ebextensions中使用container_commands会更好。
例如,您可以拥有以下文件.ebextensions/10_run_migrate.config
container_commands:
10_run_migrate:
command: 'python ./manage.py migrate'请注意,这只是一个示例。因此,该文件可能需要使用Django特定的命令或设置进行调整。
https://stackoverflow.com/questions/62949456
复制相似问题