有人可以在下面查看我的01composer.config文件,看看migrateSeed命令是否有问题,因为弹性beanstalk会出现错误Application deployment failed at 2016-06-10T15:53:58Z with exit status 1 and error: container_command 02-migrateSeed in .ebextensions/01composer.config failed.
commands:
composer_update:
command: export COMPOSER_HOME=/root && /usr/bin/composer.phar self-update
option_settings:
- namespace: aws:elasticbeanstalk:application:environment
option_name: COMPOSER_HOME
value: /root
container_commands:
01-install_dependencies:
command: "php /usr/bin/composer.phar install"
cwd: "/var/app/ondeck"
02-migrateSeed:
command: "php artisan migrate --force"
cwd: "/var/app/ondeck"
03-seed:
command: "php artisan db:seed --force"
cwd: "/var/app/ondeck"
04-optimize:
command: "php /usr/bin/composer.phar dump-autoload --optimize"
cwd: "/var/app/ondeck"
答案 0 :(得分:1)
将您的脚本更改为:
02-migrateSeed:
command: "php artisan migrate --force"
cwd: "/var/app/ondeck"
leader_only: true
03-seed:
command: "php artisan db:seed --force"
cwd: "/var/app/ondeck"
leader_only: true
我的猜测是第一个实例(领导者)正在正确播种数据,然后另一个实例尝试重新播种相同的数据,从而导致MySQL约束违规异常。
设置为true时,仅限leader的标志将确保仅在第一个实例上运行这些命令。
编辑:
查看此其他答案,了解有关leader_only的更多信息
AWS Elastic Beanstalk - why would I use leader_only for a command?