amazon beanstack policy issues when running eb create - ruby-on-rails

After running
eb create projectname to deploy my rails project to amazon beanstack
I keep getting errors these errors. I have never used this service before and thought I would give it a try.. Here are the errors.
2015-10-02 17:23:50 UTC-0400 WARN Environment health has transitioned from Pending to Degraded. Command failed on all instances.
2015-10-02 17:23:38 UTC-0400 ERROR Create environment operation is complete, but with errors. For more information, see troubleshooting documentation.
2015-10-02 17:22:35 UTC-0400 INFO Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
2015-10-02 17:22:35 UTC-0400 ERROR [Instance: i-c2e7f417] Command failed on instance. Return code: 1 Output: (TRUNCATED)...ndeck/config/environment.rb:5:in `<top (required)>' Gem::LoadError: sqlite3 is not part of the bundle. Add it to Gemfile. /var/app/ondeck/config/environment.rb:5:in `<top (required)>' Tasks: TOP => environment (See full trace by running task with --trace). Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/11_asset_compilation.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
I am thinking it has something to do with the policys? there an easier way to set policy permissions?

It's not a policy error, it's an issue with your configuration. From the error you posted, this part
(TRUNCATED)...ndeck/config/environment.rb:5:in `' Gem::LoadError: sqlite3 is not part of the bundle. Add it to Gemfile.
indicates that your database.yml is misconfigured (since it defaults to SQLite) or you don't have the sqlite3 gem installed.

Related

Why do I get NameError in heroku (rails) console after enabling enhanced language Metrics?

I enabled enhanced language metrics for the ruby language metrics in Heroku for a Ruby on Rails application, following the documentation (barnes gem etc.). This worked successfully.
Later on I saw errors when inspecting something in the system through the rails console heroku console --app my-rails-app-name. Any call of a model constant example lead to the following output:
Running console on ⬢ my-rails-app-name... up, run.8724 (Standard-1X)
irb(main):001:0> MyModel.all.count
Traceback (most recent call last):
4: from /app/vendor/bundle/bin/console:29:in `<main>'
3: from /app/vendor/bundle/bin/console:29:in `load'
2: from /app/vendor/bundle/ruby/2.6.0/gems/countries-3.0.0/bin/console:14:in `<top (required)>'
1: from (irb):1
NameError (uninitialized constant MyModel)
The work around is to run the rails console explicitly
heroku run rails console --app my-rails-app-name
Because the enhanced language metrics needs loading another build pack we can suspect that this is the reason for this. But don't give up! The order in which the build packs are executed can be configured. So drag the heroku/metrics buildpack above the heroku/ruby build pack, deploy one more time and afterwards you should be able to stick to your workflow :)

ActiveRecord::PendingMigrationError - migrating from one server to another

I'm new to Rails so please bear with me.
Currently there is an existing project (Rails 4.1.6, Ruby 2.1.3) running on digital ocean VM (Ubuntu 14.04) and its connecting to Postgresdb 9.6 without any issues. I have to migrate this to new VM.
I have setup a new vm with Ubuntu 16.04, installed Rails and Ruby with exact same versions. I tried creating a test rails app and its working fine. However, when I tried to deployed the project from old server to this new one its giving me errors.
Details:
There was an error while trying to load the gem 'uglifier'.
Gem Load Error is: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
Backtrace for gem load error is:
/usr/local/lib/ruby/gems/2.1.0/gems/execjs-2.7.0/lib/execjs /runtimes.rb:58:in `autodetect'
/usr/local/lib/ruby/gems/2.1.0/gems/execjs-2.7.0/lib/execjs.rb:5:in `<module:ExecJS>'
/usr/local/lib/ruby/gems/2.1.0/gems/execjs-2.7.0/lib/execjs.rb:4:in `<top (required)>'
/usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.1.6/lib /active_support/dependencies.rb:247:in `require'
/usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:247:in `block in require'
/usr/local/lib/ruby/gems/2.1.0/gems/activesupport-4.1.6/lib/active_support/dependencies.rb:232:in `load_dependency'
After searching on internet, most of them suggested to uncomment this line in the Gemfile.
# gem 'therubyracer', platforms: :ruby
This was commented in the old server, however, I tried uncommenting it and it came back with different error.
Migrations are pending. To resolve this issue, run: bin/rake db:migrate RAILS_ENV=development
Website was connecting to the same database and old webportal was running fine but it gave me this error. So I setup a new test db and ran the following commands -
RAILS_ENV=production bundle exec rake db:create
RAILS_ENV=production bundle exec rake db:setup
RAILS_ENV=production bundle exec rake db:migrate
All those commands were executed successfully but for some reason I'm still receiving "Migrations are pending....." error.
Please advise.
The migration-error seems to think you should be on the development environment... but the migrations you ran are for production... so either your environment-setting is not correct, or you need to run the migrations for development instead

Updating gems and aws deploy error ruby on rails

My application is running fine over Elasticbeanstalk. as i have connected my repo with gemnasium, so it said about outdated gems and i updated them.
1: First i just ran the bundle update command then deployed i got error
Creating application version archive "app-51c4-160115_105334".
Uploading evercam-admin-live/app-51c4-160115_105334.zip to S3. This may take a while.
Upload Complete.
INFO: Environment update is starting.
INFO: Deploying new version to instance(s).
ERROR: [Instance: i-40adb5c9] Command failed on instance. Return code: 1 Output: (TRUNCATED)...ror: cannot load such file -- bundler/setup
/var/app/ondeck/config/boot.rb:3:in `<top (required)>'
/var/app/ondeck/config/application.rb:1:in `<top (required)>'
/var/app/ondeck/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace).
container_command 01seed in .ebextensions/seed.config failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
INFO: Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
ERROR: Unsuccessful command execution on instance id(s) 'i-40adb5c9'. Aborting the operation.
ERROR: Failed to deploy application.
ERROR: Failed to deploy application.
After searching around over stackoverflow i found out that updating each gem separately will be better and did the same.
Gems with no version number. i did bundle update gemname and for those who are with version number i updated version number in gemfile and again did the the same bundle update gemname
2: it updated the gem as well. and then i deployed that branch again.
and got the EXACT same error again.
anyhelp will be appreciated thanks

SSHKit error during Capistrano deployment of Rails app

After installing a new gem, Slackistrano to already succesfully deployed app with Capistrano, our deployments started failing with the following error during rake assets:precompile or rake db:migrate tasks
cap aborted!
SSHKit::Command::Failed: rake stdout: Nothing written
rake stderr: Nothing written
/Users/pete/.rvm/gems/ruby-2.2.2/gems/sshkit-1.3.0/lib/sshkit/command.rb:94:in `exit_status='
This error is obviously not very helpful.
If I ran the capistrano task cap staging assets:precompile, it would succeed.
So what's going on here?
There are a few other solutions to SSHKit failures during cap deployments, but most of them were for first time deployments and didn't work for me.
Here's how I figured out the solution(after much hair pulling).
I knew that it was probably the new gem that was causing the problem. So I went into the source code for sshkit/command.rb and outputted the command it was trying to execute on the remote server.
I then logged into the remote server and ran it manually and got the following output:
$ cd /home/web/sites/site.com/releases/20160106224143 && ( RAILS_ENV=production ~/.rvm/bin/rvm default do bundle exec rake db:migrate )
rake aborted!
NoMethodError: undefined method `each_pair' for "slack:deploy:updating":String
/home/web/sites/site.com/shared/bundle/ruby/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:1602:in `compile!'
/home/web/sites/site.com/shared/bundle/ruby/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:1344:in `add_filter'
/home/web/sites/site.com/shared/bundle/ruby/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:1331:in `before'
/home/web/sites/site.com/shared/bundle/ruby/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:1989:in `block (2 levels) in delegate'
/home/web/sites/site.com/shared/bundle/ruby/2.2.0/gems/slackistrano-1.0.0/lib/slackistrano/tasks/slack.rake:121:in `<top (required)>'
So, the problem started with Slackistrano, but then, what? why is Sinatra there? I don't use Sinatra in my app.
Well, I discovered that there was a gem in my Gemfile that was for development only(mailcatcher) but was in the production section of the Gemfile. I removed this and redeployed successfully.
However, there is obviously a deeper issue because there seems to be some sort of name collision on the "before" method of sinatra and capistrano that caused this in the first place.
I'm posting here to help others debug possible SSHKit errors during Cap deployments and also perhaps to guide others on weird name collisions between Sinatra and Capistrano.
For me this issue can arise if you're accidentally on an incompatible version of Ruby whilst running Capistrano. I had to add a .ruby-version to clamp it for me to 2.7.5 whilst using gem 'capistrano', '3.11.0'.
So I'm not sure if stating Ruby version 2 or higher is strictly true.

ActiveResource 500 Internal Server Error

I am getting a really strange error from ActiveResource. I have a method that calls another system to get a list of products. The list is quite large and takes about 3 minutes to generate and transfer. Since this is really only a once a day kinda thing I built a rake task to run it. In production whenever I run the rake task it fails with a 500 error. Here is some sample output
$ time RAILS_ENV=production rake api:sync
rake aborted!
Failed with 500 Internal Server Error
(See full trace by running task with --trace)
real 2m1.753s
user 0m1.188s
sys 0m0.188s
Then I tried to use script runner:
$ RAILS_ENV=production script/runner 'Product.synchronize!(ProductManager::Product.find_valid_products)'
/var/www/apps/api/releases/20091202203413/vendor/rails/railties/lib/commands/runner.rb:48: Failed with 500 Internal Server Error (ActiveResource::ServerError)
from /usr/local/lib/ruby/1.8/net/protocol.rb:133:in `rbuf_fill'
from /usr/local/lib/ruby/1.8/timeout.rb:62:in `timeout'
from /usr/local/lib/ruby/1.8/timeout.rb:93:in `timeout'
from /usr/local/lib/ruby/1.8/net/protocol.rb:132:in `rbuf_fill'
from /usr/local/lib/ruby/1.8/net/protocol.rb:116:in `readuntil'
from /usr/local/lib/ruby/1.8/net/protocol.rb:126:in `readline'
from /usr/local/lib/ruby/1.8/net/http.rb:2020:in `read_status_line'
from /usr/local/lib/ruby/1.8/net/http.rb:2009:in `read_new'
... 17 levels...
from /var/www/apps/api/releases/20091202203413/vendor/rails/railties/lib/commands/runner.rb:48
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from script/runner:3
However if I jump into the console to run it, everything is fine:
$ script/console production
Loading production environment (Rails 2.3.5)
>> Product.synchronize!(ProductManager::Product.find_valid_products); nil # prevent dump to console
=> nil
>>
I suspected it was a timeout, so I set the timeout value to 5 minutes on the ProductManager::Product class, but that had no effect. The interesting thing is that when I run via rake or script/runner the error happens occurs at 2 minutes and 1 second without fail. In development and staging there is no issue. Does production of ActiveResource have some kind of hidden 2 minute override I can't find?
In case you didn't get it from the traces, we are using Rails 2.3.5 frozen into the application. Thanks for you help
Peer
Turns out it was an Apache setting. The RequestTimeout in the httpd.conf file was 120 seconds. Once we upped that everything was fine.

Resources