Skip to content

Instantly share code, notes, and snippets.

@wikimatze
Last active Aug 29, 2015
Embed
What would you like to do?
Deploy Padrino Apps On Anynines

Let's create a new application:

$ padrino g project hello-world-anynines-mysql -d activerecord -a mysql
    create
    create  .gitignore
    create  config.ru
    create  config/apps.rb
    create  config/boot.rb
    create  public/favicon.ico
    create  public/images
    create  public/javascripts
    create  public/stylesheets
    create  tmp
    create  .components
    create  app
    create  app/app.rb
    create  app/controllers
    create  app/helpers
    create  app/views
    create  app/views/layouts
    create  Gemfile
    create  Rakefile
  applying  activerecord (orm)...
     apply  orms/activerecord
    insert  Gemfile
    insert  Gemfile
    insert  app/app.rb
    create  config/database.rb
  skipping  test component...
  skipping  mock component...
  skipping  script component...
  applying  slim (renderer)...
     apply  renderers/slim
    insert  Gemfile
  skipping  stylesheet component...
 identical  .components
     force  .components
     force  .components

=================================================================
hello-world-anynines-mysql is ready for development!
=================================================================
$ cd ./hello-world-anynines-mysql
$ bundle
=================================================================

After running bundle to generate the Gemfile.lock, you need to login:

$ cf login
target: https://api.de.a9s.eu

Email> matthias@wikimatze.de

Password> **********

Authenticating... OK

Now, we are ready to deploy our app:

$ cf push
Name> anynines-padrino-mysql

Instances> 1

1: 128M
2: 256M
3: 512M
4: 1G
Memory Limit> 256M

Creating anynines-padrino-mysql... OK

1: anynines-padrino-mysql
2: none
Subdomain> anynines-padrino-mysql

1: de.a9sapp.eu
2: none
Domain> de.a9sapp.eu

Creating route anynines-padrino-mysql.de.a9sapp.eu... OK
Binding anynines-padrino-mysql.de.a9sapp.eu to anynines-padrino-mysql... OK

Create services for application?> y

1: elasticsearch 0.20
2: mongodb 2.0
3: mysql 5.5
4: postgresql 9.1
5: rabbitmq 2.8
6: redis 2.2
7: swift 1.0
8: user-provided , via
What kind?> 3

Name?> mysql-e26e2

1: Pluto-free: Shared VM, shared DB: free plan
2: Venus-20: Shared: 2 GB Ram, 20 GB Storage
Which plan?> 1

Creating service mysql-e26e2... OK
Binding mysql-e26e2 to anynines-padrino-mysql... OK
Create another service?> n

Bind other services to application?> n

Save configuration?> y

Saving to manifest.yml... OK
Uploading anynines-padrino-mysql... OK
Preparing to start anynines-padrino-mysql... OK
-----> Downloaded app package (12K)
-----> Downloaded app package (12K)
-----> Using Ruby version: ruby-1.9.3
-----> Installing dependencies using Bundler version 1.3.2
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment
tps://rubygems.org/.........
       Fetching gem metadata from https://rubygems.org/..
       Installing rake (10.1.1)
       Installing i18n (0.6.9)
       Installing minitest (4.7.5)
       Installing multi_json (1.9.0)
       Installing atomic (1.1.16)
       Installing thread_safe (0.2.0)
       Installing tzinfo (0.3.39)
       Installing activesupport (4.0.4)
       Installing builder (3.1.4)
       Installing activemodel (4.0.4)
       Installing activerecord-deprecated_finders (1.0.3)
       Installing arel (4.0.2)
       Installing activerecord (4.0.4)
       Installing rack (1.5.2)
       Installing url_mount (0.2.1)
       Installing http_router (0.11.1)
       Installing mime-types (1.25.1)
       Installing polyglot (0.3.4)
       Installing treetop (1.4.15)
       Installing mail (2.5.4)
       Installing moneta (0.7.20)
       Installing mysql2 (0.3.15)
       Installing rack-protection (1.5.2)
       Installing tilt (1.4.1)
       Installing sinatra (1.4.4)
       Installing thor (0.17.0)
       Installing padrino-core (0.12.0)
       Installing padrino-helpers (0.12.0)
       Installing padrino-admin (0.12.0)
       Installing padrino-cache (0.12.0)
       Using bundler (1.3.2)
       Installing padrino-gen (0.12.0)
       Installing padrino-mailer (0.12.0)
       Installing padrino (0.12.0)
       Installing temple (0.6.7)
       Installing slim (2.0.2)
       Your bundle is complete! It was installed into ./vendor/bundle
       Cleaning up the bundler cache.
-----> Writing config/database.yml to read from DATABASE_URL
-----> WARNINGS:
       You have not declared a Ruby version in your Gemfile.
       To set your Ruby version add this line to your Gemfile:"
       ruby '1.9.3'"
       # See https://devcenter.heroku.com/articles/ruby-versions for more information."
tps://rubygems.org/.........
       Fetching gem metadata from https://rubygems.org/..
       Installing rake (10.1.1)
       Installing i18n (0.6.9)
       Installing minitest (4.7.5)
       Installing multi_json (1.9.0)
       Installing atomic (1.1.16)
       Installing thread_safe (0.2.0)
       Installing tzinfo (0.3.39)
       Installing activesupport (4.0.4)
       Installing builder (3.1.4)
       Installing activemodel (4.0.4)
       Installing activerecord-deprecated_finders (1.0.3)
       Installing arel (4.0.2)
       Installing activerecord (4.0.4)
       Installing rack (1.5.2)
       Installing url_mount (0.2.1)
       Installing http_router (0.11.1)
       Installing mime-types (1.25.1)
       Installing polyglot (0.3.4)
       Installing treetop (1.4.15)
       Installing mail (2.5.4)
       Installing moneta (0.7.20)
       Installing mysql2 (0.3.15)
       Installing rack-protection (1.5.2)
       Installing tilt (1.4.1)
       Installing sinatra (1.4.4)
       Installing thor (0.17.0)
       Installing padrino-core (0.12.0)
       Installing padrino-helpers (0.12.0)
       Installing padrino-admin (0.12.0)
       Installing padrino-cache (0.12.0)
       Using bundler (1.3.2)
       Installing padrino-gen (0.12.0)
       Installing padrino-mailer (0.12.0)
       Installing padrino (0.12.0)
       Installing temple (0.6.7)
       Installing slim (2.0.2)
       Your bundle is complete! It was installed into ./vendor/bundle
       Cleaning up the bundler cache.
-----> Writing config/database.yml to read from DATABASE_URL
-----> WARNINGS:
       You have not declared a Ruby version in your Gemfile.
       To set your Ruby version add this line to your Gemfile:"
       ruby '1.9.3'"
       # See https://devcenter.heroku.com/articles/ruby-versions for more information."
Checking status of app 'anynines-padrino-mysql'...
  0 of 1 instances running (1 starting)
  1 of 1 instances running (1 running)
Push successful! App 'anynines-padrino-mysql' available at anynines-padrino-mysql.de.a9sapp.eu

Next, we need to find out the credentials for our database:

$ cf tunnel
1: mysql-e26e2
Which service instance?> 1

1: none
2: mysql
3: mysqldump
Which client would you like to start?> 2

Opening tunnel on port 10000... OK
Waiting for local tunnel to become available... OK
'mysql' execution failed; is it in your $PATH?

I need to install a proper mysql client with sudo apt-get install mysql-client-5.5. Now we need to get the credentials of the database:

$ cf tunnel
1: mysql-e26e2
Which service instance?> 1

1: none
2: mysql
3: mysqldump
Which client would you like to start?> 2

Opening tunnel on port 10000... OK
Waiting for local tunnel to become available... OK
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 523597
Server version: 5.5.29-rel29.4 Percona Server with XtraDB (GPL), Release rel29.4, Revision 401

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+-----------------------------------+
| Database                          |
+-----------------------------------+
| information_schema                |
| d52372f354f604616a03cce4680a8e126 |
+-----------------------------------+
2 rows in set (0.30 sec)

mysql> exit

But what we really need are the credentials:

1: mysql-e26e2
Which service instance?> 1

1: none
2: mysql
3: mysqldump
Which client would you like to start?> 1

Opening tunnel on port 10000... OK

Service connection info:
  username : utpQSWCohARgN
  password : ps8YnASnVGJIS
  name     : d52372f354f604616a03cce4680a8e126
  uri      : mysql://utpQSWCohARgN:ps8YnASnVGJIS@10.12.0.6:3307/d52372f354f604616a03cce4680a8e126


Open another shell to run command-line clients or
use a UI tool to connect using the displayed information.
Press Ctrl-C to exit...  

And now edit config/database.rb with the following settings:

ActiveRecord::Base.configurations[:production] = {
  :adapter   => 'mysql2',
  :encoding  => 'utf8',
  :reconnect => true,
  :database  => 'd52372f354f604616a03cce4680a8e126',
  :pool      => 5,
  :username  => 'utpQSWCohARgN',
  :password  => 'ps8YnASnVGJIS',
  :host      => '10.12.0.6',
  :socket    => '/tmp/mysql.sock'
}

And run the migrations:

$ cf push --command "PADRINO_ENV=production bundle exec rake ar:migrate"
Using manifest file manifest.yml

Not applying manifest changes without --reset

Uploading anynines-padrino-mysql... OK
Changes:
  command: '' -> 'PADRINO_ENV=production bundle exec rake ar:migrate'
Updating anynines-padrino-mysql... OK
Stopping anynines-padrino-mysql... OK

Preparing to start anynines-padrino-mysql... OK
-----> Downloaded app package (16K)
-----> Downloaded app buildpack cache (9.9M)
-----> Downloaded app package (16K)
-----> Downloaded app buildpack cache (9.9M)
r version 1.3.2
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment
       Using rake (10.1.1)
       Using i18n (0.6.9)
       Using minitest (4.7.5)
       Using multi_json (1.9.0)
       Using atomic (1.1.16)
       Using thread_safe (0.2.0)
       Using tzinfo (0.3.39)
       Using activesupport (4.0.4)
       Using builder (3.1.4)
       Using activemodel (4.0.4)
       Using activerecord-deprecated_finders (1.0.3)
       Using arel (4.0.2)
       Using activerecord (4.0.4)
       Using rack (1.5.2)
       Using url_mount (0.2.1)
       Using http_router (0.11.1)
       Using mime-types (1.25.1)
       Using polyglot (0.3.4)
       Using treetop (1.4.15)
       Using mail (2.5.4)
       Using moneta (0.7.20)
       Using mysql2 (0.3.15)
       Using rack-protection (1.5.2)
       Using tilt (1.4.1)
       Using sinatra (1.4.4)
       Using thor (0.17.0)
       Using padrino-core (0.12.0)
       Using padrino-helpers (0.12.0)
       Using padrino-admin (0.12.0)
       Using padrino-cache (0.12.0)
       Using bundler (1.3.2)
       Using padrino-gen (0.12.0)
       Using padrino-mailer (0.12.0)
       Using padrino (0.12.0)
       Using temple (0.6.7)
       Using slim (2.0.2)
       Your bundle is complete! It was installed into ./vendor/bundle
       Cleaning up the bundler cache.
-----> Writing config/database.yml to read from DATABASE_URL
-----> WARNINGS:
       You have not declared a Ruby version in your Gemfile.
       To set your Ruby version add this line to your Gemfile:"
       ruby '1.9.3'"
       # See https://devcenter.heroku.com/articles/ruby-versions for more information."
-----> Uploading droplet (27M)
Checking status of app 'anynines-padrino-mysql'...
  0 of 1 instances running (1 starting)
  0 of 1 instances running (1 starting)
  0 of 1 instances running (1 starting)
  0 of 1 instances running (1 starting)
  0 of 1 instances running (1 starting)
  0 of 1 instances running (1 crashing)
Push unsuccessful.
TIP: The system will continue to attempt restarting all requested app instances that have crashed. Try 'cf app' to monitor app status. To troubleshoot crashes, try 'cf events' and 'cf crashlogs'.

You can find the code https://github.com/matthias-guenther/hello-world-padrino-anynines-mysql

@julweber

This comment has been minimized.

Copy link

@julweber julweber commented Apr 2, 2014

Hey Matthias,

I'm happy to see your results using anynines.

I have one suggestion for your gist:

Instead of manually adding the db credentials to your config you could read them from the vcap_services environment variable. This is an example where swift service credentials are reead from the environment: https://github.com/anynines/paperclip_demo/blob/master/config/initializers/paperclip.rb#L32

Cheers,
Julian W

@wikimatze

This comment has been minimized.

Copy link
Owner Author

@wikimatze wikimatze commented Apr 15, 2014

Hi Julian, thanks for your help and I know what you mean. I add the following settings in my config/database.rb:

ActiveRecord::Base.configurations[:production] = {
  :adapter   => 'mysql2',
  :encoding  => 'utf8',
  :reconnect => true,
  :database  => JSON.parse(ENV["VCAP_SERVICES"])["mysql-5.5"].first['credentials']['name'],
  :pool      => 5,
  :username  => JSON.parse(ENV["VCAP_SERVICES"])["mysql-5.5"].first['credentials']['username'],
  :password  => JSON.parse(ENV["VCAP_SERVICES"])["mysql-5.5"].first['credentials']['password'],
  :host      => JSON.parse(ENV["VCAP_SERVICES"])["mysql-5.5"].first['credentials']['hostname'],
  :socket    => '/tmp/mysql.sock'
}

And after running cf push --command "PADRINO_ENV=production bundle exec rake ar:migrate" the app crashed again with the following output:

Using manifest file manifest.yml

Not applying manifest changes without --reset

Uploading padrino-mysql... OK
Changes:
  command: '' -> 'PADRINO_ENV=production bundle exec rake ar:migrate'
Updating padrino-mysql... OK
Stopping padrino-mysql... OK

Preparing to start padrino-mysql... OK
-----> Downloaded app package (16K)
-----> Downloaded app buildpack cache (11M)
-----> Downloaded app package (16K)
-----> Downloaded app buildpack cache (11M)
-----> Using Ruby version: ruby-1.9.3
-----> Installing dependencies using Bundler version 1.3.2
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment
       Using rake (10.2.2)
       Using i18n (0.6.9)
       Using json (1.8.1)
       Using minitest (5.3.3)
       Using thread_safe (0.3.3)
       Using tzinfo (1.1.0)
       Using activesupport (4.1.0)
       Using builder (3.2.2)
       Using activemodel (4.1.0)
       Using arel (5.0.1.20140414130214)
       Using activerecord (4.1.0)
       Using coderay (1.1.0)
       Using rack (1.5.2)
       Using url_mount (0.2.1)
       Using http_router (0.11.1)
       Using mime-types (1.25.1)
       Using polyglot (0.3.4)
       Using treetop (1.4.15)
       Using mail (2.5.4)
       Using method_source (0.8.2)
       Using moneta (0.7.20)
       Using mysql2 (0.3.15)
       Using rack-protection (1.5.3)
       Using tilt (1.4.1)
       Using sinatra (1.4.5)
       Using thor (0.17.0)
       Using padrino-core (0.12.0)
       Using padrino-helpers (0.12.0)
       Using padrino-admin (0.12.0)
       Using padrino-cache (0.12.0)
       Using bundler (1.3.2)
       Using padrino-gen (0.12.0)
       Using padrino-mailer (0.12.0)
       Using padrino (0.12.0)
       Using slop (3.4.7)
       Using pry (0.9.12.6)
       Using temple (0.6.7)
       Using slim (2.0.2)
       Your bundle is complete! It was installed into ./vendor/bundle
       Cleaning up the bundler cache.
-----> Writing config/database.yml to read from DATABASE_URL
-----> WARNINGS:
       You have not declared a Ruby version in your Gemfile.
       To set your Ruby version add this line to your Gemfile:"
       ruby '1.9.3'"
       # See https://devcenter.heroku.com/articles/ruby-versions for more information."
Checking status of app 'padrino-mysql'...
  0 of 1 instances running (1 starting)
  0 of 1 instances running (1 down)
  0 of 1 instances running (1 crashing)
Push unsuccessful.
TIP: The system will continue to attempt restarting all requested app instances that have crashed. Try 'cf app' to monitor app status. To troubleshoot crashes, try 'cf events' and 'cf crashlogs'.

Checking the crashlogs gives me the following:

wikimatze~/git-repositories/hello-world-anynines-mysql2: cf crashlogs padrino-mysql
Getting logs for padrino-mysql #6b6e7c04fbcfc8b4d240d67d79dde62a... OK

Reading logs/env.log... OK
TMPDIR=/home/vcap/tmp
VCAP_CONSOLE_IP=0.0.0.0
VCAP_APP_PORT=62455
USER=vcap
VCAP_APPLICATION={"instance_id":"6b6e7c04fbcfc8b4d240d67d79dde62a","instance_index":0,"host":"0.0.0.0","port":62455,"started_at":"2014-04-15 05:10:43 +0000","started_at_timestamp":1397538643,"start":"2014-04-15 05:10:43 +0000","state_timestamp":1397538643,"limits":{"mem":256,"disk":1024,"fds":16384},"application_version":"df61defd-882e-4eae-8a46-a96ddc0bd083","application_name":"padrino-mysql","application_uris":["padrino-mysql.de.a9sapp.eu"],"version":"df61defd-882e-4eae-8a46-a96ddc0bd083","name":"padrino-mysql","uris":["padrino-mysql.de.a9sapp.eu"],"users":null}
RACK_ENV=production
PATH=/home/vcap/app/bin:/home/vcap/app/vendor/bundle/ruby/1.9.1/bin:/bin:/usr/bin:/bin:/usr/bin
PWD=/home/vcap
LANG=en_US.UTF-8
VCAP_SERVICES={"mysql-5.5":[{"name":"mysql-e4cfd","label":"mysql-5.5","tags":["relational"],"plan":"Pluto-free","credentials":{"name":"d1817c6e97f554353bcf33fdc7b98eedd","hostname":"10.12.0.6","host":"10.12.0.6","port":3307,"user":"u0ZTZtvOwHWxF","username":"u0ZTZtvOwHWxF","password":"pmNFfVTpbDkxb","uri":"mysql://u0ZTZtvOwHWxF:pmNFfVTpbDkxb@10.12.0.6:3307/d1817c6e97f554353bcf33fdc7b98eedd"}}]}
SHLVL=1
HOME=/home/vcap/app
GEM_PATH=/home/vcap/app/vendor/bundle/ruby/1.9.1:
PORT=62455
VCAP_APP_HOST=0.0.0.0
DATABASE_URL=mysql2://u0ZTZtvOwHWxF:pmNFfVTpbDkxb@10.12.0.6:3307/d1817c6e97f554353bcf33fdc7b98eedd
MEMORY_LIMIT=256m
VCAP_CONSOLE_PORT=62456
_=/usr/bin/env



Reading logs/staging_task.log... OK
-----> Downloaded app package (16K)
-----> Downloaded app buildpack cache (11M)
-----> Using Ruby version: ruby-1.9.3
-----> Installing dependencies using Bundler version 1.3.2
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment
       Using rake (10.2.2)
       Using i18n (0.6.9)
       Using json (1.8.1)
       Using minitest (5.3.3)
       Using thread_safe (0.3.3)
       Using tzinfo (1.1.0)
       Using activesupport (4.1.0)
       Using builder (3.2.2)
       Using activemodel (4.1.0)
       Using arel (5.0.1.20140414130214)
       Using activerecord (4.1.0)
       Using coderay (1.1.0)
       Using rack (1.5.2)
       Using url_mount (0.2.1)
       Using http_router (0.11.1)
       Using mime-types (1.25.1)
       Using polyglot (0.3.4)
       Using treetop (1.4.15)
       Using mail (2.5.4)
       Using method_source (0.8.2)
       Using moneta (0.7.20)
       Using mysql2 (0.3.15)
       Using rack-protection (1.5.3)
       Using tilt (1.4.1)
       Using sinatra (1.4.5)
       Using thor (0.17.0)
       Using padrino-core (0.12.0)
       Using padrino-helpers (0.12.0)
       Using padrino-admin (0.12.0)
       Using padrino-cache (0.12.0)
       Using bundler (1.3.2)
       Using padrino-gen (0.12.0)
       Using padrino-mailer (0.12.0)
       Using padrino (0.12.0)
       Using slop (3.4.7)
       Using pry (0.9.12.6)
       Using temple (0.6.7)
       Using slim (2.0.2)
       Your bundle is complete! It was installed into ./vendor/bundle
       Cleaning up the bundler cache.
-----> Writing config/database.yml to read from DATABASE_URL
-----> WARNINGS:
       You have not declared a Ruby version in your Gemfile.
       To set your Ruby version add this line to your Gemfile:"
       ruby '1.9.3'"
       # See https://devcenter.heroku.com/articles/ruby-versions for more information."



Reading logs/stderr.log... OK
Environment variable PADRINO_ENV is deprecated. Please, use RACK_ENV.
rake aborted!
Mysql2::Error: Can't connect to MySQL server on '10.12.0.6' (111)
/home/vcap/app/vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.15/lib/mysql2/client.rb:67:in `connect'
/home/vcap/app/vendor/bundle/ruby/1.9.1/gems/mysql2-0.3.15/lib/mysql2/client.rb:67:in `initialize'
/home/vcap/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.0/lib/active_record/connection_adapters/mysql2_adapter.rb:18:in `new'
/home/vcap/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.0/lib/active_record/connection_adapters/mysql2_adapter.rb:18:in `mysql2_connection'
/home/vcap/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:435:in `new_connection'
/home/vcap/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:445:in `checkout_new_connection'
/home/vcap/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `acquire_connection'
/home/vcap/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:351:in `block in checkout'
/home/vcap/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:350:in `checkout'
/home/vcap/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block in connection'
/home/vcap/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connection'
/home/vcap/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:541:in `retrieve_connection'
/home/vcap/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.0/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/home/vcap/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.0/lib/active_record/connection_handling.rb:87:in `connection'
/home/vcap/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.0/lib/active_record/migration.rb:910:in `initialize'
/home/vcap/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.0/lib/active_record/migration.rb:807:in `new'
/home/vcap/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.0/lib/active_record/migration.rb:807:in `up'
/home/vcap/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.0/lib/active_record/migration.rb:785:in `migrate'
/home/vcap/app/vendor/bundle/ruby/1.9.1/gems/padrino-gen-0.12.0/lib/padrino-gen/padrino-tasks/activerecord.rb:127:in `block (2 levels) in <top (required)>'
Tasks: TOP => ar:migrate
(See full trace by running task with --trace)



Reading logs/stdout.log... OK

Again, problems with the connections. Maybe it's a port problem or something else?
Thanks for your help.

@julweber

This comment has been minimized.

Copy link

@julweber julweber commented Apr 22, 2014

Hey Matthias,

sorry for the delayed response.

This is what i did to make it work:

  • Port -> database.rb:
    ActiveRecord::Base.configurations[:production] = {
    :adapter => 'mysql2',
    :encoding => 'utf8',
    :reconnect => true,
    :database => JSON.parse(ENV["VCAP_SERVICES"])["mysql-5.5"].first['credentials']['name'],
    :pool => 5,
    :username => JSON.parse(ENV["VCAP_SERVICES"])["mysql-5.5"].first['credentials']['username'],
    :password => JSON.parse(ENV["VCAP_SERVICES"])["mysql-5.5"].first['credentials']['password'],
    :host => JSON.parse(ENV["VCAP_SERVICES"])["mysql-5.5"].first['credentials']['hostname'],
    :port => JSON.parse(ENV["VCAP_SERVICES"])["mysql-5.5"].first['credentials']['port']
    }
  • Migration Command:
    cf push --command 'RACK_ENV=production bundle exec rake ar:migrate'
  • Start Command:
    cf push --command 'RACK_ENV=production bundle exec padrino start -p $PORT -h $VCAP_APP_HOST'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment