5

I'm new to Beanstalk. I've created a Rails application and set the database production configuration to use the environment variables hopefully provided by AWS. I'm using Mysql (mysql2 gem), and want to use RDS and Passenger (I have no preference there).

On my development environment I can run the rails application with my local Mysql (it is just a basic application I've created for experimentation). I have added the passenger gem to Gemfile and bundled, but I'm using WEBBrick in development still.

The only thing I did not do by the book is that I did not use 'eb' but rather tried from the console. My application/environment failed to run as while "rake db:migrate" it still thinks I wanted it to connect to the local Mysql (I guess from the logs that it is not aware of RACK_ENV and hence uses 'development').

Any tip? I can of course try next the 'eb', yet would prefer to work with the console.

Regards, Oren

Oren
  • 976
  • 9
  • 23
  • I have also tried with 'eb' and also with 'RACK_ENV' and 'RAILS_ENV' in 'myapp,config' under .ebextensions . I'm really puzzled. Can't be that hard, everyone uses AWS these days, no? – Oren Jun 07 '15 at 20:42

4 Answers4

2

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

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

smad
  • 1,071
  • 14
  • 29
1

Have you tried to run

    bin/rake db:migrate RAILS_ENV=development

? I got the same issue and that worked for me.

Yahs Hef
  • 797
  • 9
  • 24
1

I recommend you enter to EC2 instance through this command "eb ssh" (The first time you need specified you .pem file, if you have not one you can create in IAM services) and check your logs for more information about yours error.

If you have problems when you are uploading your code (eb deploy) you have the log in this file: "/var/log/eb-activity.log" (Remember this file is in your EC2 instance)

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

Other recommedations is install EB CLI version 3. for manage your eb instance

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

0

I believed that Elastic Beanstalk will run 'rake db:migrate' by itself. Indeed it seems to try, but that is failing. I gave my bounty to 'Yahs Hef', even though I will only try this evening (UK). My disorientation with AWS caused me to forget this easy solution, of running the migration by myself. If this does not work by itself, I'll simplify the database configuration as possibile.

Oren
  • 976
  • 9
  • 23
  • It works. It was my stupidity. Once I've tried to run the migration by myself, I've realized I've forgot a '=' in '<% RDS..' (should be '<%= RDS..' of course. Other from that, setting the secret, maybe with yet another environment variable, and it just works. – Oren Jun 21 '15 at 16:21