Сбой команды контейнера при развертывании
Я пытаюсь развернуть свой проект Django с помощью Elastic Beanstalk. Все было хорошо, пока не попытался запустить команды контейнера. Вот как выглядит мой .config файл:
container_commands:
01_migrate:
command: "source /var/app/venv/*/bin/activate && python3 manage.py migrate"
leader_only: true
02_createsuperuser: # <- The error occurs here
command: "echo \"from account.models import Account; Account.objects.create_superuser('Me', 'Me', 'myemail@gmail.com', 'superadmin', 'MyPassword')\" | python3 manage.py shell"
И мой файл cfn.init регистрирует эту ошибку:
[ERROR] Command 02_createsuperuser (echo "from account.models import Account; Account.objects.create_superuser('Me', 'Me', 'myemail@gmail.com', 'superadmin', 'MyPassword')" | python3 manage.py shell) failed
2021-12-06 03:22:18,662 [ERROR] Error encountered during build of postbuild_0_package404: Command 02_createsuperuser failed
Traceback (most recent call last):
File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 573, in run_config
CloudFormationCarpenter(config, self._auth_config).build(worklog)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 273, in build
self._config.commands)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/command_tool.py", line 127, in apply
raise ToolError(u"Command %s failed" % name)
cfnbootstrap.construction_errors.ToolError: Command 02_createsuperuser failed
2021-12-06 03:22:18,665 [ERROR] -----------------------BUILD FAILED!------------------------
2021-12-06 03:22:18,665 [ERROR] Unhandled exception during build: Command 02_createsuperuser failed
Traceback (most recent call last):
File "/opt/aws/bin/cfn-init", line 176, in <module>
worklog.build(metadata, configSets)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 135, in build
Contractor(metadata).build(configSets, self)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 561, in build
self.run_config(config, worklog)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 573, in run_config
CloudFormationCarpenter(config, self._auth_config).build(worklog)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/construction.py", line 273, in build
self._config.commands)
File "/usr/lib/python3.7/site-packages/cfnbootstrap/command_tool.py", line 127, in apply
raise ToolError(u"Command %s failed" % name)
cfnbootstrap.construction_errors.ToolError: Command 02_createsuperuser failed
Как я могу решить эту проблему? Я постараюсь предоставить дополнительную информацию, если вам это необходимо.
Попробовал и сработало :D
02_createsuperuser:
command: "source /var/app/venv/*/bin/activate && and so on..."