Tamby Kojak
Tamby Kojak

Reputation: 2159

OpsWorks gets deployed, but non of my actions work. Is my database.yml file messing things up?

When I run my rails server locally with a local mysql server, my endpoints work fine and things are being inserted and updated to the mysql database and everything is just beautiful.

When I deploy to AWS OpsWorks, however, the application get's deployed and I'm able to see what's in the /public folder, but all my actions don't work and I'm not quite sure how to debug this.

When I check the log, see that bundle install gets called, and even then following...

[2014-07-13T14:37:34+00:00] INFO: No database adapter specified for bgs_api, guessing
[2014-07-13T14:37:35+00:00] INFO: Looks like bgs_api uses mysql2 in its Gemfile

.. but nothing regarding the actual creation of the tables or execution of the migrations.

About my instance and app...

I have one EC2 instance that has both the Rails and MySQL layers on it.

I'm using a database.yml file, but I'm not sure if this means that I can ignore putting in the custom JSON when deploying the application. Which is what I'm currently doing.

Here is my database.yml file

development:
  adapter: mysql2
  encoding: utf8
  reconnect: true
  database: xyz #name for local database defined by me
  username: abc #username for local database user defined by me
  password: 123 #password for local database user defined by me
  pool: 5
  host: localhost

production:
  adapter: mysql2
  encoding: utf8
  reconnect: true
  database: xyz #name for opsworks database defined by me
  username: root #username for opsworks database defined by opsworks
  password: abc #password for opsworks database defined by opsworks
  pool: 5
  host: localhost

One particular thing I'm not sure about is the production host value... I imagine it would be localhost because this get's run on the ec2 insatnce.

Any help or direction for debugging would be of great help. Thank you!

Upvotes: 1

Views: 469

Answers (1)

Imran Ahmed
Imran Ahmed

Reputation: 1066

You need to send in the database details via custom JSON. This is because the APP doesn't have the connection details automatically from the configurations. Even if you do add it into the codebase, it'll get over written by the recipes.

{
  "deploy":{
    "app_name":{
      "database":{
        "password":"",
        "adapter":"mysql2",
        "username":"",
        "database":"",
        "host":"localhost"
      }
    }
  }
}

You need to run normal task that does create your database etc. This is something you should do to seperately as part of installing the app. A good option would be to use the deployment hooks : opsworks hooks

Upvotes: 1

Related Questions