Anthony Candaele

Joined

1,530 Experience
1 Lesson Completed
1 Question Solved

Activity

found it, because on the vps I don't have a development environment, I need to start the Rails console in the 'current' folder with:

RAILS_ENV=production bundle exec rails c

Posted in Ruby issue when doing cap deploy production

Hi Chris, James,

Just successfully deployed my Rails app on a Digital Ocean VPS ( a small step for mankind but a giant leap for a devops newbie):

http://95.85.5.6

thanks a lot for your help and patience,

greetings,

Anthony

Hi,

I just successfully deployed my Rails app to a Digital Ocean VPS, following the Deploy Rails guide on this website. Many thanks go to Chris Oliver and James Dullaghan for their help and patience.

Now my app is deployed, I need to create an admin user so I can log in and start to create content.

On heroku I was able manipulate the database through the Rails console, with the command:

heroku run rails console

However, I'm not sure how to manually enter data in the database on my VPS.
Can I also spin a Rails console and access the production database, or do I need to do this another way?

Thanks for your help,

Anthony

Posted in Ruby issue when doing cap deploy production

Hi Chris, thanks a lot, adding the secrets.yml file to config/deploy.rb solved the issue : )

I'm still not there, as a couple of other challenges await me like dealing with these failure messages:

DEBUG[f06a4082] Finished in 0.081 seconds with exit status 1 (failed).
DEBUG[09ba02b5] Running /usr/bin/env [ -f /home/deploy/posplus/releases/20140914083548/config/database.yml ] on <my-ip>

I'm getting a couple of these error messages when deploying with Capistrano.

Also there seem to be some issues with assets:

    DEBUG[da33561d]     I, [2014-09-14T04:36:06.122787 #24469]  INFO -- : Writing           /home/deploy/posplus/releases/20140914083548/public/assets/belfort-081a4bbefd8f4ed5f27bbb624d48f379.png
   DEBUG[da33561d]  I, [2014-09-14T04:36:06.125691 #24469]  INFO -- : Writing     /home/deploy/posplus/releases/20140914083548/public/assets/jigsaw-puzzle-1c07a986767187bd9961fe69651705c8.jpg
   DEBUG[da33561d]  I, [2014-09-14T04:36:06.127459 #24469]  INFO -- : Writing /home/deploy/posplus/releases/20140914083548/public/assets/logo-posplus-72x61-c0cc65a8684ac8d9da5d402fcbc58c6e.png
   DEBUG[da33561d]  I, [2014-09-14T04:36:06.129307 #24469]  INFO -- : Writing /home/deploy/posplus/releases/20140914083548/public/assets/logo-posplus-a0276666c4cf6aaeb387a2580cdefc71.png
   DEBUG[da33561d]  I, [2014-09-14T04:36:06.139111 #24469]  INFO -- : Writing /home/deploy/posplus/releases/20140914083548/public/assets/member_placeholder-66af4d62c5dc83d72c054cf50caea6d5.png

But again I'm a step further in my quest to deploy a Rails app on a VPS

thanks for your patience,

Anthony

Posted in Ruby issue when doing cap deploy production

Hi Chris, thanks, I wasn't aware of that and changed the carrier_wave.rb initializer:

CarrierWave.configure do |config|
  if Rails.env.staging? || Rails.env.production?
    config.storage = :fog
    config.fog_credentials = {
      :provider               => 'AWS',                        # required
      :aws_access_key_id      => Rails.application.secrets.S3_KEY,                        # required
      :aws_secret_access_key  => Rails.application.secrets.S3_SECRET,                        # required
    }
    config.fog_directory  = 'posplus'                     # required
  else
    config.storage = :file
    config.enable_processing = Rails.env.production?
  end
end

and my secrets.yml file looks like this:

production:
  S3_KEY: <%= ENV['S3_KEY'] %>
  S3_SECRET: <%= ENV['S3_SECRET'] %>

Then it also struck my that I working in a feature branch called 'capistrano' so I added

set :branch, 'capistrano'

to my config/deploy.rb file and I pushed the feature branch to a remote branch on Github

But I'm still getting the same error when doing 'cap production deploy':

DEBUG[e90c10e8] Command: cd /home/deploy/posplus/releases/20140914000558 && ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.1.2     RAILS_ENV=production ~/.rbenv/bin/rbenv exec bundle exec rake assets:precompile )
DEBUG[e90c10e8]     rake aborted!
DEBUG[e90c10e8]     ArgumentError: Missing required arguments: aws_access_key_id, aws_secret_access_key
DEBUG[e90c10e8]     /home/deploy/posplus/shared/bundle/ruby/2.1.0/gems/fog-core-1.24.0/lib/fog/core/service.rb:237:in     `validate_options'

sigh : (

I don't know why Capistranno isn't picking up the changes. Right now I'm not sure if this could be related to the problems I had with the creation of a postgres user.

Maybe you guys are seeing things I don't see? My remote feature branch is at:

https://github.com/acandael/posplus-rails/tree/capistrano

greetings,

Anthony

Posted in Ruby issue when doing cap deploy production

Hi James, thanks for the help,

I did put the hard coded keys in the secrets.yml file and also sourced the ~/.bashrc file. But it didn't solve the issue. Capistrano keeps giving me the error:

INFO[97d4f95a] Running ~/.rbenv/bin/rbenv exec bundle exec rake assets:precompile on 95.85.5.6
DEBUG[97d4f95a] Command: cd /home/deploy/posplus/releases/20140913135409 && ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.1.2     RAILS_ENV=production ~/.rbenv/bin/rbenv exec bundle exec rake assets:precompile )
DEBUG[97d4f95a]     rake aborted!
DEBUG[97d4f95a]     ArgumentError: Missing required arguments: aws_access_key_id, aws_secret_access_key

If this could clear things up, my config/initializers/carrier_wave.rb file looks like this:

CarrierWave.configure do |config|
  if Rails.env.staging? || Rails.env.production?
    config.storage = :fog
    config.fog_credentials = {
      :provider               => 'AWS',                        # required
      :aws_access_key_id      => ENV['S3_KEY'],                        # required
      :aws_secret_access_key  => ENV['S3_SECRET'],                        # required
    }
    config.fog_directory  = 'posplus'                     # required
  else
    config.storage = :file
    config.enable_processing = Rails.env.production?
  end
end

I always worked on Heroku, where I set the environment variables with the 'heroku set:config ....' command.

greetings,

Anthony

Posted in Ruby issue when doing cap deploy production

man this is hard, I put the environment variable S3_KEY and S3_SECRET in different files:

~/.bashrc
/etc/default/nginx
home/deploy/posplus/shared/config/secrets.yml

but none solved the problem, I'm stil getting this error message when I try to do 'cap production deploy':

DEBUG[ff424d92]     rake aborted!
DEBUG[ff424d92]     ArgumentError: Missing required arguments: aws_access_key_id, aws_secret_access_key
DEBUG[ff424d92]     /home/deploy/posplus/shared/bundle/ruby/2.1.0/gems/fog-core-1.22.0/lib/fog/core/service.rb:237:in `validate_options'

Posted in Ruby issue when doing cap deploy production

thanks Chris, will try this out

greetings,

Anthony

Posted in Ruby issue when doing cap deploy production

I tried to add the environment variables to my vps environment with:

export S3_KEY='my key ...'
export S3_SECRET='my secret key'

but I'm keep getting the same error when I run 'cap production deploy':

DEBUG[4f41f85f]     rake aborted!
DEBUG[4f41f85f]     ArgumentError: Missing required arguments: aws_access_key_id, aws_secret_access_key
DEBUG[4f41f85f]     /home/deploy/posplus/shared/bundle/ruby/2.1.0/gems/fog-core-1.22.0/lib/fog/core/service.rb:237:in `validate_options'

Posted in Ruby issue when doing cap deploy production

I configured the production database and now the capistrano script is passing the production database error.

Now I'm bumping into another error:

rake aborted!
DEBUG[53a69508]     ArgumentError: Missing required arguments: aws_access_key_id, aws_secret_access_key
DEBUG[53a69508]     /home/deploy/posplus/shared/bundle/ruby/2.1.0/gems/fog-core-1.22.0/lib/fog/core/service.rb:237:in `validate_options'

I guess this errror is related to the fact that my app is using Carrierwave and Fog and is storing uploaded images to Amazon S3.

Does this errror mean I should create Environment Variables for aws_access_key_id and aws_secret_access_key?

thanks for your help,

Anthony

Posted in Ruby issue when doing cap deploy production

ok, now I guess I ran into the Posgres issue, I reported on:

DEBUG[00c3d123]     rake aborted!
DEBUG[00c3d123]     ActiveRecord::AdapterNotSpecified: 'production' database is not configured. Available: []

I tried to solve this by adding settings for the production server in my local config.database.yml file

production:
  database: <database>
  adapter: postgresql
  encoding: unicode
  pool: 5
  username: <username> 
  password: <password>

but I keep getting the same error message:

rake aborted!
DEBUG[ffcbeda7]     ActiveRecord::AdapterNotSpecified: 'production' database is not configured. Available: []
DEBUG[ffcbeda7]     /home/deploy/posplus/shared/bundle/ruby/2.1.0/gems/activerecord-    4.1.1/lib/active_record/connection_adapters/connection_specification.rb:257:in `resolve_symbol_connection'

Posted in Ruby issue when doing cap deploy production

this is harder then I thought, I installed the bundler gem and now the next error is:

DEBUG[a18e2f6c]     rake aborted!
DEBUG[a18e2f6c]     ExecJS::RuntimeUnavailable: Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.
DEBUG[a18e2f6c]     /home/deploy/posplus/shared/bundle/ruby/2.1.0/gems/execjs-2.2.1/lib/execjs/runtim

Googled this issue, seems I have to install Node.js with:

sudo apt-get install nodejs

Posted in Ruby issue when doing cap deploy production

Moved on again with the deployment proces, but the deployment still fails. Now there seems to be a problem with the bundle command

DEBUG[020e32cd] Command: cd /home/deploy/posplus/releases/20140904144347 && ( RBENV_ROOT=~/.rbenv RBENV_VERSION=2.1.2    ~/.rbenv/bin/rbenv exec bundle install --binstubs /home/deploy/posplus/shared/bin --path /home/deploy/posplus/shared/bundle --without   development test --deployment --quiet )
DEBUG[020e32cd]     rbenv: bundle: command not found

cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host 95.85.5.6: bundle exit status: 127
bundle stdout: Nothing written
bundle stderr: rbenv: bundle: command not found

Posted in Ruby issue when doing cap deploy production

ok, again one step further

I ran

ssh-add ~/.ssh/id_rsa

in the terminal

and ran a new

cap deploy production

the deploy proces moved on, but then it failed with

Finished in 0.029 seconds with exit status 1 (failed).
ERRORlinked file /home/deploy/posplus/shared/config/database.yml does not exist on 95.85.5.6

I guess this has to do with the issue about creating the Postgres user which I reported about on this forum under the thread 'setup Postgres user fails'

Posted in Ruby issue when doing cap deploy production

ok,

using

set :rbenv_ruby, '2.1.2'

fixed it.

However now I'm running in this error:

[62800640]  Warning: Permanently added 'github.com,some id' (RSA) to the list of known hosts.
DEBUG[62800640]     Permission denied (publickey).
DEBUG[62800640]     fatal: Could not read from remote repository.
DEBUG[62800640]     
DEBUG[62800640]     Please make sure you have the correct access rights
DEBUG[62800640]     and the repository exists.
DEBUG[62800640] Finished in 0.745 seconds with exit status 128 (failed).

Posted in setup Postgres user fails

when I switch to the postgres user and run

dropuser postgres

I get

dropuser: removal of role "postgres" failed: ERROR:  current user cannot be dropped

Posted in Ruby issue when doing cap deploy production

when I run

ls ~/.rbenv/versions/2.1.2-p95

on the vps, I get

ls: cannot access /home/deploy/.rbenv/versions/2.1.2-p95: No such file or directory

Posted in Ruby issue when doing cap deploy production

Hi Chris,

when I run the command as deploy user on the vps

which ~/.rbenv/versions/2.1.2-p95

I get no output, just a new cursor line

when I run

which ruby

I get

/home/deploy/.rbenv/shims/ruby

when I run

ruby -v

I get

ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]

I also try to solve the issue by changing the line in my Capfile from

set :rbenv_ruby, '2.1.2-p95'

to

set :rbenv_ruby, '2.1.2p95'

but that didn't fix it.

Posted in setup Postgres user fails

Hi,

I'm following the Deploy Rails guide

I'm now a the part where Postgres gets installed. I successfully installed Postgres, but when I try to create a new Postgres user with:

createuser --pwprompt

, I'm getting this message:

creation of new role failed: ERROR:  role "postgres" already exists

anyone knows what's going on?

thanks for your help,

Anthony

Posted in deploy Rails

you also may run into this issue when first doing an ssh login:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
<some key>
Please contact your system administrator.
Add correct host key in /Users/youraccount/.ssh/known_hosts to get rid of this message.
Offending RSA key in /Users/youraccount/.ssh/known_hosts:12
RSA host key for <your host ip-address> has changed and you have requested strict checking.
Host key verification failed.

To fix this I run:

ssh-keygen -R [host ip-address]

I found the solution on Stack Overflow: http://stackoverflow.com/questions/20840012/ssh-remote-host-identification-has-changed

hope this might help someone running in the same issue as I am,

Anthony

Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

© 2024 GoRails, LLC. All rights reserved.