0

Could someone please see my 01composer.config file below and see if there's something wrong with the migrateSeed command, as elastic beanstalk gives the error 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"
omrakhur
  • 1,362
  • 2
  • 24
  • 48

1 Answers1

1

Change your script to:

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

My guess is that the data is being seeded correctly by the first instance (leader) and then another instance is trying to re-seed the same data causing a MySQL constraint violation exception.

When set to true, the leader only flag will make sure to run those commands only on the first instance.

EDIT:

Checkout this other answer for more info about leader_only

AWS Elastic Beanstalk - why would I use leader_only for a command?

Community
  • 1
  • 1
scrubmx
  • 2,486
  • 19
  • 24
  • I have tried that and it's still not working. The problem is, as I have found out, the EC2 classic platform isn't supported in my region and therefore under ELB configuration, it says I don't have a database, whereas in reality I have an RDS database. I need to connect it to that. I am just not sure how I'm supposed to do it. The environment properties are all set e.g. DB_HOST, DB_NAME, etc. are all set using values from RDS, but still not connecting – omrakhur Jun 13 '16 at 09:31