Spring will not start - ruby-on-rails

I am receiving the following error when trying to start Spring (https://github.com/jonleighton/spring). I am running it in a Vagrant box with Ubuntu 12.04 LTS 12.04.
vagrant#rails-starter-box:/vagrant/ticketee$ spring start
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/spring-0.0.8/lib/spring/server.rb:85:in `unlink': Text file busy - /vagrant/ticketee/tmp/spring/spring.pid (Errno::ETXTBSY)
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/spring-0.0.8/lib/spring/server.rb:85:in `unlink'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/spring-0.0.8/lib/spring/server.rb:85:in `block (2 levels) in set_exit_hook'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/spring-0.0.8/lib/spring/server.rb:84:in `each'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/spring-0.0.8/lib/spring/server.rb:84:in `block in set_exit_hook'
/usr/local/rvm/gems/ruby-1.9.3-p194/gems/spring-0.0.8/lib/spring/server.rb:34:in `initialize': Operation not permitted - /vagrant/ticketee/tmp/spring/spring (Errno::EPERM)
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/spring-0.0.8/lib/spring/server.rb:34:in `open'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/spring-0.0.8/lib/spring/server.rb:34:in `boot'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/spring-0.0.8/lib/spring/server.rb:15:in `boot'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/spring-0.0.8/lib/spring/client/start.rb:13:in `call'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/spring-0.0.8/lib/spring/client/command.rb:7:in `call'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/spring-0.0.8/lib/spring/client.rb:23:in `run'
from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/spring-0.0.8/bin/spring:4:in `'
from /usr/local/rvm/gems/ruby-1.9.3-p194/bin/spring:19:in `load'
from /usr/local/rvm/gems/ruby-1.9.3-p194/bin/spring:19:in `'
from /usr/local/rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `eval'
from /usr/local/rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `'

Because of Vagrant's read-only file system you need environment set the variable SPRING_TMP_PATH to somewhere outside of the /vagrant directory
run this at the command line
mkdir ~/spring_tmp; export SPRING_TMP_PATH=/home/vagrant/spring_tmp
spring start
then run
spring status
if spring is now running then add the following line to ~/.bashrc
export SPRING_TMP_PATH="/home/vagrant/spring_tmp" # Temp PATH for spring
Credit for this goes to George Brocklehurst

I got this error with RSpec. I had to mount /windows via SMB (cifs) from a shared folder. I also had to change the permissions on the shared folder to grant write access. You can either grant Full Control to Everyone, or Full Control to your Windows user, but then you have to mount with permissions.
mount -t cifs //10.0.2.2/aidc /windows -o credentials=/etc/samba/credentials,uid=500,gid=500
You also have to install Samba (cifs?) too in your Virtual Box.
I heard vboxfs is really bad and doesn't handle a large number of files.

Related

Discourse server fails to start with errors related to redis

Rails server fails to start in Discourse project either in development or production. Below are the logs when trying to start the server in dev mode. The application was installed and has been working, It's deployed on AWS in production mode and restarting the unicorn loads the application for some time and again the url stops responding with error messages.
Development logs from $rails s
rb t#ip-XXX-XX-XX-XX-app:/var/www/discourse# vi
config/environments/development.r
root#ip-172-31-25-46-app:/var/www/discourse# rails s
=> Booting Puma
=> Rails 5.1.4 application starting in production
=> Run `rails server -h` for more startup options
Exiting
bundler: failed to load command: script/rails (script/rails)
Redis::CommandError: ERR Error running script (call to f_b06356ba4628144e123b652c99605b873107c9be): #user_script:14: #user_script: 14: -MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/redis-3.3.5/lib/redis/client.rb:121:in `call'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/redis-3.3.5/lib/redis.rb:2399:in `block in _eval'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/redis-3.3.5/lib/redis.rb:58:in `block in synchronize'
/usr/local/lib/ruby/2.4.0/monitor.rb:214:in `mon_synchronize'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/redis-3.3.5/lib/redis.rb:58:in `synchronize'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/redis-3.3.5/lib/redis.rb:2398:in `_eval'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/redis-3.3.5/lib/redis.rb:2450:in `evalsha'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/message_bus-2.1.1/lib/message_bus/backends/redis.rb:380:in `cached_eval'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/message_bus-2.1.1/lib/message_bus/backends/redis.rb:140:in `publish'
/var/www/discourse/vendor/bundle/ruby/2.4.0/gems/message_bus-2.1.1/lib/message_bus.rb:248:in `publish'
/var/www/discourse/lib/distributed_cache.rb:72:in `publish'
**Production logs **
/var/www/discourse/lib/demon/base.rb:109:in `ensure_running'
/var/www/discourse/lib/demon/base.rb:34:in `block in ensure_running'
/var/www/discourse/lib/demon/base.rb:33:in `each'
/var/www/discourse/lib/demon/base.rb:33:in `ensure_running'
config/unicorn.conf.rb:145:in `master_sleep'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/unicorn-5.1.0/lib/unicorn/http_server.rb:284:in `join'
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/unicorn-5.1.0/bin/unicorn:126:in `<top (required)>'
/var/www/discourse/vendor/bundle/ruby/2.3.0/bin/unicorn:23:in `load'
/var/www/discourse/vendor/bundle/ruby/2.3.0/bin/unicorn:23:in `<main>'
E, [2018-01-04T08:43:37.949928 #60] ERROR -- : reaped #<Process::Status: pid 5870 exit 1> worker=unknown
Detected dead worker 5870, restarting...
Loading Sidekiq in process id 5883
Failed to report error: MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error. 4 Redis::CommandError (MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk. Commands that may modify the data set are disabled. Please check Redis logs for details about the error.)
/var/www/discourse/vendor/bundle/ruby/2.3.0/gems/redis-3.3.0/lib/redis/client.rb:121:in `call' web-exception
Redis logs
47:M 17 Jan 09:38:01.070 # Can't save in background: fork: Cannot allocate memory
47:M 17 Jan 09:38:07.087 * 10000 changes in 60 seconds. Saving...
The issue has been fixed, Edited this file
/etc/sysctl.conf and added the line at last
vm.overcommit_memory=1
After this restarted sysctl.
$ sudo sysctl -p /etc/sysctl.conf
Redis doesn't need the amount of memory which OS thinks, the status 1 means always overcommit, never check.
More details can be found from Redis Docs.

Booting up Vagrant from Jenkins throws Permission Denied

I am trying to Boot up Vagrant VM from Jenkins. I gave Vagrantfile path in 'Boot up Vagrant VM'.
When the job runs, I get the following error:
Failed to iterate on remote directory vagrant_projs
[ vagrant ]: Executing command :[vagrant, up] in folder /Users/abc/Desktop/vagrant_projs
[vagrant_projs] $ vagrant up
[ vagrant ]: Error starting up vagrant, caught IOException, message: Cannot run program "vagrant" (in directory "/Users/abc/Desktop/vagrant_projs"): error=13, Permission denied
[ vagrant ]: [Ljava.lang.StackTraceElement;#5e144dc9
Build step 'Boot up Vagrant VM' marked build as failure
Finished: FAILURE
I thought it might be because of permissions of Vagrantfile and thus I have chmod 777 to it manually. Even after that it gives me the same error.
UPDATE:
I moved the folder in which Vagrantfile resided from Desktop to user folder and I got different stacktrace.
[workspace] $ vagrant -v
Vagrant 1.7.2
[ vagrant ]: Executing command :[vagrant, up] in folder /Users/abalan15/vagrant_projs
[vagrant_projs] $ vagrant up
/opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:313:in `unlink': Permission denied - /Users/abalan15/vagrant_projs/.vagrant/machines/default/virtualbox/id (Errno::EACCES)
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:313:in `delete'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:313:in `id='
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/machine.rb:142:in `initialize'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/vagrantfile.rb:75:in `new'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/vagrantfile.rb:75:in `machine'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:614:in `machine'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/plugin/v2/command.rb:168:in `block in with_target_vms'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/plugin/v2/command.rb:192:in `call'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/plugin/v2/command.rb:192:in `block in with_target_vms'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/plugin/v2/command.rb:174:in `each'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/plugin/v2/command.rb:174:in `with_target_vms'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/plugins/commands/up/command.rb:74:in `block in execute'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:277:in `block (2 levels) in batch'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:275:in `tap'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:275:in `block in batch'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:274:in `synchronize'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:274:in `batch'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/plugins/commands/up/command.rb:58:in `execute'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/cli.rb:42:in `execute'
from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/environment.rb:301:in `cli'
from /opt/vagrant/bin/../embedded/gems/gems/vagrant-1.7.2/bin/vagrant:174:in `<main>'
Build step 'Boot up Vagrant VM' marked build as failure
Finished: FAILURE
At last!
When we try to invoke/boot Vagrant VM from Jenkins(with vagrant plugin), .vagrant.d & folder with vagrantfile will be invoked. Permission for the jenkins user should be given to these folders.
In mac, right click on these folders, get info, on the bottom(permissions), click the + symbol and add jenkins to the 'Users & Groups'
A few things to check when dealing with permission problems in Jenkins:
What user name is running the container (Tomcat) or the Jenkins native binary?
What user name is the jenkins process / jnlp / slave using (if this isn't on the master Jenkins node)

Can't start jruby rails server on Windows because it can't find ncursesw

I can't seem to get the server to start for some reason, I keep getting this cryptic error.
C:\src\marvel\server\script>jruby rails server
c:/tools/jruby/lib/ruby/site_ruby/shared/ffi/library.rb:28:in `ffi_lib': Could n
(LoadError)ary 'ncursesw' : The operation completed successfully.
. Could not open library 'ncursesw.dll' : The operation completed successfully.
. Could not open library 'ncurses' : The operation completed successfully.
. Could not open library 'ncurses.dll' : The operation completed successfully.
from c:/tools/jruby/lib/ruby/site_ruby/shared/ffi/library.rb:10:in `map'
from c:/tools/jruby/lib/ruby/site_ruby/shared/ffi/library.rb:10:in `ffi_
lib'
from c:/tools/jruby/lib/ruby/gems/1.8/gems/ffi-ncurses-0.3.3/lib/ffi-ncu
rses.rb:32
from c:/tools/jruby/lib/ruby/gems/1.8/gems/ffi-ncurses-0.3.3/lib/ffi-ncu
rses.rb:64:in require'
from c:/tools/jruby/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/run
time.rb:64:inrequire'
from c:/tools/jruby/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/run
time.rb:62:in each'
from c:/tools/jruby/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/run
time.rb:62:inrequire'
from c:/tools/jruby/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/run
time.rb:51:in each'
from c:/tools/jruby/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/run
time.rb:51:inrequire'
from c:/tools/jruby/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler.rb:
112:in require'
from C:/src/marvel/server/config/application.rb:9
from C:/src/marvel/server/config/application.rb:28:inrequire'
from c:/tools/jruby/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/comm
ands.rb:28
from c:/tools/jruby/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/comm
ands.rb:27:in tap'
from c:/tools/jruby/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/comm
ands.rb:27
from c:/tools/jruby/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/comm
ands.rb:6:inrequire'
from rails:6
I figured it out, I don't need ncurses on Windows, so I just commented it out from my gemfile. It appears that Jruby cannot distinguish between windows and *nix, so it blows up without special care.

getaddrinfo: nodename nor servname provided, or not known

I have a Ruby on Rails application that I am deploying on a computer running Mac OS X 10.6. The code where the problem arises is run by a delayed_job. The problem only occurs when it is run through delayed_job. If I run it within a console (rails console production) or call the API directly through cURL, it works without any problems. Also, the entire process works without issue in my development environment.
Basically, the code works in one place, but for some reason, fails where it has to work. I've searched and found a few resources, but none of the suggestions apply or make any difference. When I log into the server and run the commands, everything works. But for some reason when they are run/started by Capistrano, it doesn't work.
Any help is greatly appreciated.
Important notes:
Ruby version: 1.9.2-p0
Rails version: 3.0.1
delayed_job version: latest (from collectiveidea/delayed_job)
rest-client version: 1.6.1
Code:
class CallApi < Struct.new(:num)
def perform
log "Entering perform"
apinum = num || 5
log "ApiNum = #{apinum}"
results = attempt(2,10) do
ActiveSupport::JSON.decode(RestClient.get(API_URL, {:params => {:apinum => apinum}}))
end
log "Results retrieved. (count: #{results.count})"
end
def log(message)
Delayed::Worker.logger.info "[CallApi] #{Time.now} - #{message}"
end
end
Environment Config (note: the url is fake, but of the same form as the real one):
API_URL = "http://api.example.org/api_endpoint"
# Originally, I had "http://" before the beginning, but found a
# post mentioning that Net::Http.start didn't like that.
# So I tried it both ways.
# The same error occurs regardless of if the "http://" is there.
Call where the error happens:
RestClient.get(API_URL, {:params => {:apinum => apinum}})
Error:
getaddrinfo: nodename nor servname provided, or not known
/Users/api/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/net/http.rb:644:in `initialize'
/Users/api/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/net/http.rb:644:in `open'
/Users/api/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/net/http.rb:644:in `block in connect'
/Users/api/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/timeout.rb:44:in `timeout'
/Users/api/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/timeout.rb:87:in `timeout'
/Users/api/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/net/http.rb:644:in `connect'
/Users/api/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/net/http.rb:637:in `do_start'
/Users/api/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/net/http.rb:626:in `start'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/gems/rest-client-1.6.1/lib/restclient/request.rb:166:in `transmit'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/gems/rest-client-1.6.1/lib/restclient/request.rb:60:in `execute'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/gems/rest-client-1.6.1/lib/restclient/request.rb:31:in `execute'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/gems/rest-client-1.6.1/lib/restclient.rb:68:in `get'
/private/var/www/project-gemset/releases/20101109002137/lib/call_api.rb:7:in `block in perform'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/gems/attempt-0.2.0/lib/attempt.rb:70:in `attempt'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/gems/attempt-0.2.0/lib/attempt.rb:114:in `attempt'
/private/var/www/project-gemset/releases/20101109002137/lib/call_api.rb:6:in `perform'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/bundler/gems/delayed_job-aba9905764c2/lib/delayed/backend/base.rb:77:in `invoke_job'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/bundler/gems/delayed_job-aba9905764c2/lib/delayed/worker.rb:118:in `block (2 levels) in run'
/Users/api/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/timeout.rb:57:in `timeout'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/bundler/gems/delayed_job-aba9905764c2/lib/delayed/worker.rb:118:in `block in run'
/Users/api/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/benchmark.rb:309:in `realtime'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/bundler/gems/delayed_job-aba9905764c2/lib/delayed/worker.rb:117:in `run'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/bundler/gems/delayed_job-aba9905764c2/lib/delayed/worker.rb:176:in `reserve_and_run_one_job'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/bundler/gems/delayed_job-aba9905764c2/lib/delayed/worker.rb:102:in `block in work_off'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/bundler/gems/delayed_job-aba9905764c2/lib/delayed/worker.rb:101:in `times'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/bundler/gems/delayed_job-aba9905764c2/lib/delayed/worker.rb:101:in `work_off'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/bundler/gems/delayed_job-aba9905764c2/lib/delayed/worker.rb:76:in `block (2 levels) in start'
/Users/api/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/benchmark.rb:309:in `realtime'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/bundler/gems/delayed_job-aba9905764c2/lib/delayed/worker.rb:75:in `block in start'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/bundler/gems/delayed_job-aba9905764c2/lib/delayed/worker.rb:72:in `loop'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/bundler/gems/delayed_job-aba9905764c2/lib/delayed/worker.rb:72:in `start'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/bundler/gems/delayed_job-aba9905764c2/lib/delayed/command.rb:100:in `run'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/bundler/gems/delayed_job-aba9905764c2/lib/delayed/command.rb:79:in `block in run_process'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/gems/daemons-1.1.0/lib/daemons/application.rb:250:in `call'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/gems/daemons-1.1.0/lib/daemons/application.rb:250:in `block in start_proc'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/gems/daemons-1.1.0/lib/daemons/daemonize.rb:199:in `call'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/gems/daemons-1.1.0/lib/daemons/daemonize.rb:199:in `call_as_daemon'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/gems/daemons-1.1.0/lib/daemons/application.rb:254:in `start_proc'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/gems/daemons-1.1.0/lib/daemons/application.rb:294:in `start'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/gems/daemons-1.1.0/lib/daemons/application_group.rb:159:in `block (2 levels) in start_all'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/gems/daemons-1.1.0/lib/daemons/application_group.rb:158:in `fork'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/gems/daemons-1.1.0/lib/daemons/application_group.rb:158:in `block in start_all'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/gems/daemons-1.1.0/lib/daemons/application_group.rb:157:in `each'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/gems/daemons-1.1.0/lib/daemons/application_group.rb:157:in `start_all'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/gems/daemons-1.1.0/lib/daemons/controller.rb:80:in `run'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/gems/daemons-1.1.0/lib/daemons.rb:193:in `block in run_proc'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/gems/daemons-1.1.0/lib/daemons/cmdline.rb:112:in `call'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/gems/daemons-1.1.0/lib/daemons/cmdline.rb:112:in `catch_exceptions'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/gems/daemons-1.1.0/lib/daemons.rb:192:in `run_proc'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/bundler/gems/delayed_job-aba9905764c2/lib/delayed/command.rb:78:in `run_process'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/bundler/gems/delayed_job-aba9905764c2/lib/delayed/command.rb:72:in `block in daemonize'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/bundler/gems/delayed_job-aba9905764c2/lib/delayed/command.rb:70:in `times'
/Users/api/.rvm/gems/ruby-1.9.2-p0#project-gemset/bundler/gems/delayed_job-aba9905764c2/lib/delayed/command.rb:70:in `daemonize'
script/delayed_job:5:in `'
The error occurs when the DNS resolution fails. Check if you can wget (or curl) the api url from the command line. Changing the DNS server and testing it might help.
I ran into a similar situation today - deploying an app to a mac os x server, and receiving the 'getaddrinfo' message when I tried to access an external api. It turns out that the error occurs when the ssh session that originally launched the app is no longer active. That's why everything works perfectly if you ssh into your server and run commands manually (or launch the server manually) - as long as you keep your ssh session alive, this error won't occur.
Whether this is a bug or a quirk in OS X, I'm not sure. Here's the page that led me to the solution - http://lists.apple.com/archives/unix-porting/2010/Jul/msg00001.html
All I had to do was update my capistrano task to launch the app using 'nohup'. So changing
run "cd #{current_path} && RAILS_ENV=production unicorn_rails -c config/unicorn.rb -D"
to
run "cd #{current_path} && RAILS_ENV=production nohup unicorn_rails -c config/unicorn.rb -D"
did the trick for me.
Hope this helps somebody - it was quite a pain to figure out!
I fixed this problem simply by closing and reopening the Terminal.
rest-client's RestClient needs the http: scheme when resolving the URL. It calls Net::HTTP for you, which doesn't want the http: part, but rest-client takes care of that.
Is the URL the actual one you are attempting to reach? example.org is a valid domain used for testing and documentation and is reachable; I'd expect the "api" and "api_endpoint" parts to fail and see that when I try to reach them.
require 'socket'
IPSocket.getaddress('example.org') # => "2620:0:2d0:200::10"
IPSocket.getaddress('api.example.org') # =>
# ~> -:7:in `getaddress': getaddrinfo: nodename nor servname provided, or not known (SocketError)
# ~> from -:7:in `<main>'
Here's what I get using Curl:
greg-mbp-wireless:~ greg$ curl api.example.org/api_endpoint
curl: (6) Couldn't resolve host 'api.example.org'
greg-mbp-wireless:~ greg$ curl example.org/api_endpoint
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /api_endpoint was not found on this server.</p>
<hr>
<address>Apache Server at example.org Port 80</address>
</body></html>
greg-mbp-wireless:~ greg$ curl example.org
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<TITLE>Example Web Page</TITLE>
</HEAD>
<body>
<p>You have reached this web page by typing "example.com",
"example.net","example.org&quot
or "example.edu" into your web browser.</p>
<p>These domain names are reserved for use in documentation and are not available
for registration. See <a href="http://www.rfc-editor.org/rfc/rfc2606.txt">RFC
2606</a>, Section 3.</p>
</BODY>
</HTML>
I got the same error when I check the localhost is set in hosts file it is somehow not set. Setting localhost to 127.0.0.1 solved it.
sudo vi /etc/hosts
>>
127.0.0.1 localhost
I restarted my computer (Mac Mountain Lion) and the problem fixed itself. Something having to do with the shell thinking it was disconnected from the internet I think.
Restarting your shell in some definite way may solve this problem as well. Simply opening up a new session/window however did not work.
To avoid this problem, we can bind to 127.0.0.1 instead of localhost:
bin/rails server -b 127.0.0.1
I was seeing this error unrelated to rails. It turned out my test was trying to use a port that was too high (greater than 65535).
This code will produce the error in question
require 'socket'
Socket.getaddrinfo("127.0.0.1", "65536")
For me, I had to change a line of code in my local_env.yml to get the rspec tests to run.
I had originally had:
REDIS_HOST: 'redis'
and changed it to:
REDIS_HOST: 'localhost'
and the test ran fine.
In my config/application.yml
I have changed this
redis:
url: "redis://redis:6379/0"
to this
redis:
url: "redis://localhost:6379/0"
and it works for me
I got the error while trying to develop while disconnected to the Internet. However, the website I was working on needs to be able to talk to some other websites, so it choked when it couldn't do so. Connecting to the internet fixed the error.
If all of the above fails, try to convert to UNIX Line Endings, or do:
brew install dos2unix
sudo dos2unix -c mac /private/etc/hosts
Maybe the hosts encoding is wrong.
hope this helps
I had this problem running rake db:create. This page clued me into the DNS issue. I checked my VPN connection and found it was disconnected for some reason. I reconnected and now rake worked without a hitch.

Heroku and Refinerycms: Application failed to start ~ attachment_fu problem

Ok so I'm trying to get Refinerycms working with Heroku, and I'm new at all of this. I've set up an amazon s3 account and added keys and ids to the amazon_s3.yml files.
When launched on Heroku at gart.heroku.com I get the following error:
App failed to start
/disk1/home/slugs/141557_e8490b3_d5eb/mnt/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/s3_backend.rb:187:in read': No such file or directory - /disk1/home/slugs/141557_e8490b3_d5eb/mnt/config/amazon_s3.yml (Errno::ENOENT)
from /disk1/home/slugs/141557_e8490b3_d5eb/mnt/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/s3_backend.rb:187:inincluded'
from /disk1/home/slugs/141557_e8490b3_d5eb/mnt/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:123:in include'
from /disk1/home/slugs/141557_e8490b3_d5eb/mnt/vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:123:inhas_attachment'
from /disk1/home/slugs/141557_e8490b3_d5eb/mnt/app/models/image.rb:13
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:inrequire'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:158:in require'
from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:265:inrequire_or_load'
... 42 levels...
from /usr/local/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/builder.rb:29:in instance_eval'
from /usr/local/lib/ruby/gems/1.8/gems/rack-1.0.1/lib/rack/builder.rb:29:ininitialize'
from /home/heroku_rack/heroku.ru:1:in `new'
from /home/heroku_rack/heroku.ru:1
The s3_backend.rb line 187 contains:
##s3_config = ##s3_config = YAML.load(ERB.new(File.read(##s3_config_path)).result)[RAILS_ENV].symbolize_keys
Any help would be great!
Firstly check that your amazon_s3.yml file is checked in to git, if it is then you could try manually specifying the location somehow. If the class in s3_backend.rb has a way to set the path, you could do something like this:
S3Backend.s3_config_path = #{RAILS_ROOT}/config/amazon_s3.yml"
I'd recommend putting that in an initializer.

Resources