Rake db: migrate working on AWS Beanstalk development

I am new to Beanstalk. I created a Rails application and set up a database production configuration to use the environment variables that we hope AWS provided. I use Mysql (mysql2 gem) and want to use RDS and Passenger (I have no preferences there).

In my development environment, I can run the rails application using my local Mysql (this is just the base application I created for experimenting). I added a gem to the Gemfile and bundled, but I still use WEBBrick in development.

The only thing I did not do in the book was that I did not use "eb", but rather tried from the console. My application / environment failed to start while "rake db: migrate" still thinks I want it to connect to the local Mysql (I think from the logs that it does not know RACK_ENV and therefore uses "development") .

What advice? I can, of course, try the following "eb", but would prefer to work with the console.

Regards, Oren

+5
source share
4 answers

You tried to run

bin/rake db:migrate RAILS_ENV=development 

? I have the same problem and it worked for me.

+3
source

In Elastic Beanstalk (both in the web console and in cli) you can pass environment variables. If you pass the variable RAKE_ENV , you will change your environment.

After that, you still need to pass the parameters of your database (db password, name, ...), which should not be hardcoded in the code.

+2
source

I recommend that you enter an EC2 instance using this " eb ssh " command (the first time you need to specify a .pem file, if you don’t have one, you can create IAM services ) and check your logs for more information about your error.

If you have problems downloading the code (eb deploy), you have a log in this file: " /var/log/eb-activity.log " (remember that this file is located in your EC2 instance)

If you have problems with your application, you can read the logs in these files: " /var/app/support/logs/production.log " or " /var/application/support/logs/passenger.log "

Other recommendations are to install EB CLI version 3. to manage your eb instance

http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-install.html

+1
source

I thought Elastic Beanstalk would run "rake db: migrate" on its own. Actually, this seems to be an attempt, but it fails. I gave my Yahs Hef award, although I will only try in the evening (UK). My disorientation with AWS made me forget this simple solution, migrate on my own. If this does not work on its own, I will simplify setting up the database whenever possible.

0
source

All Articles