Rails.cache.read in sidekiq process - ruby-on-rails

In my Ruby on Rails application I have model that looks like this:
class Schema < ActiveRecord::Base
has_many :schema_items
def self.from_cache(schema_id)
schema = Rails.cache.read("schema_#{schema_id}")
unless schema
schema = Schema.where(id: schema_id).includes(:schema_items).first
Rails.cache.write("schema_#{schema_id}", schema) if schema
end
schema
end
end
I'm using this class method in other class which is called by Sidekiq worker. From time to time it returns the following error:
NotImplementedError
Using google I found this issue in redis_store gem: https://github.com/redis-store/redis-store/issues/74
But they fix this bug. My app is hosted on Heroku and I'm using the RedisCloud. Any ideas how can I solve this?
EDIT:
Here is the full backtrace:
NotImplementedError: NotImplementedError
from celluloid/tasks/task_fiber.rb:15:in `block in create'
from celluloid/tasks.rb:57:in `block in initialize'
from celluloid/actor.rb:357:in `block in task'
from celluloid/cell.rb:71:in `block in task'
from celluloid/cell.rb:60:in `block in invoke'
from celluloid/calls.rb:122:in `dispatch'
from celluloid/calls.rb:26:in `dispatch'
from celluloid/calls.rb:26:in `public_send'
from sidekiq/processor.rb:50:in `process'
from sidekiq/processor.rb:98:in `stats'
from sidekiq/processor.rb:51:in `block in process'
from sidekiq/middleware/chain.rb:132:in `invoke'
from sidekiq/middleware/chain.rb:132:in `call'
from sidekiq/middleware/chain.rb:129:in `block in invoke'
from sidekiq/middleware/server/logging.rb:11:in `call'
from sidekiq/logging.rb:30:in `with_context'
from sidekiq/middleware/server/logging.rb:15:in `block in call'
from sidekiq/middleware/chain.rb:129:in `block in invoke'
from sidekiq/failures/middleware.rb:9:in `call'
from sidekiq/middleware/chain.rb:129:in `block in invoke'
from sidekiq/middleware/server/retry_jobs.rb:74:in `call'
from sidekiq/middleware/chain.rb:129:in `block in invoke'
from sidekiq/middleware/server/active_record.rb:6:in `call'
from sidekiq/middleware/chain.rb:129:in `block in invoke'
from sidekiq/batch/middleware.rb:25:in `call'
from sidekiq/middleware/chain.rb:129:in `block in invoke'
from sidekiq_unique_jobs/middleware/server/unique_jobs.rb:16:in `call'
from sidekiq/middleware/chain.rb:129:in `block in invoke'
from sidetiq/middleware/history.rb:8:in `call'
from sidekiq/middleware/chain.rb:129:in `block in invoke'
from new_relic/agent/instrumentation/sidekiq.rb:29:in `call'
from new_relic/agent/instrumentation/controller_instrumentation.rb:352:in `perform_action_with_newrelic_trace'
from new_relic/agent/instrumentation/sidekiq.rb:33:in `block in call'
from sidekiq/middleware/chain.rb:127:in `block in invoke'
from sidekiq/processor.rb:52:in `block (2 levels) in process'
from sidekiq/processor.rb:75:in `execute_job'
from app/workers/response_processor_worker.rb:8:in `perform'
from app/services/import/response_processor.rb:28:in `process'
from app/models/import/importer/raw_response_validator.rb:17:in `validate'
from app/models/survey_schema.rb:51:in `from_cache'
from active_record/relation/finder_methods.rb:127:in `first'
from active_record/relation/finder_methods.rb:484:in `find_nth'
from active_record/relation/finder_methods.rb:500:in `find_nth_with_limit'
from active_record/relation.rb:243:in `to_a'
from active_record/relation.rb:514:in `load'
from active_record/relation.rb:643:in `exec_queries'
from active_record/relation.rb:643:in `each'
from active_record/relation.rb:644:in `block in exec_queries'
from active_record/associations/preloader.rb:102:in `preload'
from active_record/associations/preloader.rb:102:in `flat_map'
from active_record/associations/preloader.rb:102:in `each'
from active_record/associations/preloader.rb:103:in `block in preload'
from active_record/associations/preloader.rb:115:in `preloaders_on'
from active_record/associations/preloader.rb:143:in `preloaders_for_one'
from active_record/associations/preloader.rb:143:in `flat_map'
from active_record/associations/preloader.rb:143:in `each'
from active_record/associations/preloader.rb:144:in `block in preloaders_for_one'
from active_record/associations/preloader.rb:144:in `map'
from active_record/associations/preloader.rb:144:in `each'
from active_record/associations/preloader.rb:146:in `block (2 levels) in preloaders_for_one'
from active_record/associations/preloader/association.rb:20:in `run'
from active_record/associations/preloader/collection_association.rb:13:in `preload'
from active_record/associations/preloader/association.rb:78:in `associated_records_by_owner'
from active_record/associations/preloader/association.rb:60:in `owners_by_key'
from active_record/associations/preloader/association.rb:103:in `key_conversion_required?'
from active_record/associations/preloader/association.rb:107:in `association_key_type'
from active_record/associations/preloader/association.rb:45:in `association_key_name'
and my worker looks like this:
class ResponseCreatorWorker
include Sidekiq::Worker
sidekiq_options queue: :response_processing
def perform(schema_id)
# some not important code
schema = Schema.from_cache(schema_id) # this line throws the error
Response.create(schema: schema)
end
end

A couple options without being able to go into the Pro code:
Error you found is redis-store related, try memcached
Try moving the cache to memcached, it should be a simple and non-disruptive action, cost-free on simple plans, and see if the problem goes away, or changes, could be useful for hunting the core bug down
memcache is a better caching service anyway for simple key-value stuff,
The worker you linked is not a part of the stack trace
You showed the ResponseCreatorWorker, but that does not appear in the stack trace. What appears is ResponseProcessorWorker, maybe link that worker instead?
Are you sure you are running the code you are running?
Mike Perham says that the Sidekiq backtrace doesn't match the version you have given him, and the wrong worker is in the stack trace? Are you really sure the server is updating? Review the deployment log and log in to the worker with heroku run bash and inspect a couple of key files, make sure nothing is off with the platform.
Can you rescue it? :D
It should be pretty safe to put in a rescue that catches NotImplementedError, tries once again, and logs a record of it into the logs. Update gems when appropriate and when warnings disappear open a whiskey and celebrate.
Put something like this in your model:
def wrap_me_scotty
yield
rescue NotImplementedError => e
warn "#{e} :-("
yield # try once more, let it explode if no joy
end
and then wrap Rails.cache calls
def self.from_cache(schema_id)
schema = wrap_me_scotty{ Rails.cache.read("schema_#{schema_id}") }
unless schema
schema = Schema.where(id: schema_id).includes(:schema_items).first
wrap_me_scotty{ Rails.cache.write("schema_#{schema_id}", schema) } if schema
end
schema
end

Related

Converting to Mongoid causes error: Could not load database configuration - No such file - [config/database.yml]

Disclaimer: I know there are a couple of questions regarding this issue, but I followed all the answers. posted in those questions and I am still getting the error.
I have a rails app setup using Postgres and am trying to switch to mongoid. Here are the steps I took:
drop databases
add 'mongoid', '~> 7.0.5' and delete 'pg' gem
remove all references to active_record and active_storage
remove spring gems (known to cause issues)
update all models to be compatible with mongodb
delete config/database.yml and /db directory
switch devise and database-cleaner to use mongoid
After following all of the above steps, I am still getting the error when starting the server:
Could not load database configuration - No such file - [config/database.yml]
This doesn't make any sense, because rails should not be loading active record at all, and therefore should not be loading the database config file.
I would really appreciate if someone could be debug this issue.
You can view the source code of my app under the branch mongodb
Edit: I disabled bootsnap and devise and got the stack trace down to this: (It looks like active_record is still being loaded)
Puma caught this error: Cannot load database configuration:
Could not load database configuration. No such file - ["config/database.yml"] (RuntimeError)
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/railties-6.0.3.2/lib/rails/application/configuration.rb:241:in `database_configuration'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/railtie.rb:200:in `block (2 levels) in <class:Railtie>'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:71:in `class_eval'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:71:in `block in execute_hook'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:61:in `with_execution_control'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:66:in `execute_hook'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:51:in `each'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/base.rb:327:in `<module:ActiveRecord>'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/base.rb:27:in `<top (required)>'
/Users/afamily/.rvm/rubies/ruby-2.7.1/lib/ruby/gems/2.7.0/gems/zeitwerk-2.3.0/lib/zeitwerk/kernel.rb:23:in `require'
/Users/afamily/.rvm/rubies/ruby-2.7.1/lib/ruby/gems/2.7.0/gems/zeitwerk-2.3.0/lib/zeitwerk/kernel.rb:23:in `require'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activerecord-6.0.3.2/lib/active_record/query_cache.rb:31:in `run'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/execution_wrapper.rb:28:in `before'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:428:in `block in make_lambda'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:200:in `block (2 levels) in halting'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:605:in `block (2 levels) in default_terminator'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:604:in `catch'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:604:in `block in default_terminator'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:201:in `block in halting'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:513:in `block in invoke_before'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:513:in `each'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:513:in `invoke_before'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/callbacks.rb:134:in `run_callbacks'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/execution_wrapper.rb:111:in `run!'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/execution_wrapper.rb:73:in `block in run!'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/execution_wrapper.rb:70:in `tap'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/activesupport-6.0.3.2/lib/active_support/execution_wrapper.rb:70:in `run!'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/actionpack-6.0.3.2/lib/action_dispatch/middleware/executor.rb:12:in `call'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/actionpack-6.0.3.2/lib/action_dispatch/middleware/static.rb:126:in `call'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/rack-2.2.3/lib/rack/sendfile.rb:110:in `call'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/actionpack-6.0.3.2/lib/action_dispatch/middleware/host_authorization.rb:82:in `call'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/webpacker-4.2.2/lib/webpacker/dev_server_proxy.rb:23:in `perform_request'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/rack-proxy-0.6.5/lib/rack/proxy.rb:57:in `call'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/railties-6.0.3.2/lib/rails/engine.rb:527:in `call'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/puma-4.3.5/lib/puma/configuration.rb:228:in `call'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/puma-4.3.5/lib/puma/server.rb:713:in `handle_request'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/puma-4.3.5/lib/puma/server.rb:472:in `process_client'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/puma-4.3.5/lib/puma/server.rb:328:in `block in run'
/Users/afamily/.rvm/gems/ruby-2.7.1/gems/puma-4.3.5/lib/puma/thread_pool.rb:134:in `block in spawn_thread'
I believe this is the same issue as https://github.com/rails/spring/issues/601, in your case originating from devise here:
/home/sandbox/agilely/vendor/bundle/ruby/2.7.0/gems/devise-4.7.2/lib/devise/models/confirmable.rb:52:in `block in <module:Confirmable>'
If you remove devise from your application and you are able to load console successfully, I suggest reporting this issue to devise.

Psych::BadAlias: Unknown alias: 1 when running rake jobs:work

Something strange is happening with my application when I boot the jobs server with rake jobs:work. The rails webserver boots fine. I've noticed threads such as this one, however 1) it's not quite the same error message, that one seems more straightforward and 2) the answer did not yield any different results.
Here's my stacktrace -
rake aborted!
Psych::BadAlias: Unknown alias: 1
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/psych_ext.rb:77:in `visit_Psych_Nodes_Mapping'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/psych_ext.rb:35:in `visit_Psych_Nodes_Mapping'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/psych_ext.rb:35:in `visit_Psych_Nodes_Mapping'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/psych_ext.rb:17:in `load_dj'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/backend/base.rb:85:in `payload_object'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/backend/base.rb:74:in `name'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/worker.rb:245:in `job_say'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/worker.rb:272:in `handle_failed_job'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/worker.rb:213:in `block in run'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/lifecycle.rb:61:in `block in initialize'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/lifecycle.rb:66:in `execute'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/lifecycle.rb:40:in `run_callbacks'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/worker.rb:213:in `rescue in run'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/worker.rb:202:in `run'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/worker.rb:280:in `block in reserve_and_run_one_job'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/lifecycle.rb:61:in `block in initialize'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/lifecycle.rb:66:in `execute'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/lifecycle.rb:40:in `run_callbacks'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/worker.rb:280:in `reserve_and_run_one_job'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/worker.rb:187:in `block in work_off'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/worker.rb:186:in `times'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/worker.rb:186:in `work_off'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/worker.rb:150:in `block (4 levels) in start'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/worker.rb:149:in `block (3 levels) in start'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/lifecycle.rb:61:in `block in initialize'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/lifecycle.rb:66:in `execute'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/lifecycle.rb:40:in `run_callbacks'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/worker.rb:148:in `block (2 levels) in start'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/worker.rb:147:in `loop'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/worker.rb:147:in `block in start'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/plugins/clear_locks.rb:7:in `block (2 levels) in <class:ClearLocks>'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/lifecycle.rb:79:in `block (2 levels) in add'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/lifecycle.rb:61:in `block in initialize'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/lifecycle.rb:79:in `block in add'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/lifecycle.rb:66:in `execute'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/lifecycle.rb:40:in `run_callbacks'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/worker.rb:146:in `start'
/Users/ccromar/.rvm/gems/ruby-2.4.0/gems/delayed_job-4.0.6/lib/delayed/tasks.rb:9:in `block (2 levels) in <top (required)>'
I got the same issue after ruby upgrade from 2.1.5 to 2.3.8. Thats latest ruby version that could be run with rails 4.1.8.
Upgrading to the latest version of delayed_job did not help. Also tried to specify downgraded version of psych gem in my Gemfile. This did work not as well.
The real issue is that if error appears on job parsing stage then delayed_job does not update last_error column.
So I just went though all the jobs and checked if it could be parsed or not:
failing_jobs = []
Delayed::Job.find_each do |job|
begin
# this code is from dj source https://github.com/collectiveidea/delayed_job/blob/master/lib/delayed/psych_ext.rb#L15
yaml = job.handler
result = Psych.parse(yaml)
result ? Delayed::PsychExt::ToRuby.create.accept(result) : result
rescue Psych::BadAlias => e
failing_jobs << job
end
end
In my case it were 6 jobs out of ~3k that could be deleted safely so I got lucky :)
Refs:
https://github.com/collectiveidea/delayed_job/pull/867
https://github.com/collectiveidea/delayed_job_mongoid/pull/65

Delayed Jobs failing in production on the server

All my delayed jobs are failing for no apparent reason in production on the server. I tried restarting, removing all previous jobs and again starting the job worker, but nothing worked.
Suspecting it must be a capistrano issue, I manually ran rake jobs:work via ssh on the server but I got the same error:
ubuntu#ip-172-31-35-0:~/apps/instano-api/current$ rake jobs:work
[Worker(host:ip-172-31-35-0 pid:22174)] Starting job worker
[Worker(host:ip-172-31-35-0 pid:22174)] Job InstanoMailer.new_quote (id=73) RUNNING
[Worker(host:ip-172-31-35-0 pid:22174)] Job InstanoMailer.new_quote (id=73) FAILED (3 prior attempts) with NameError: undefined method `error' for class `Class'
I use ExceptionNotifier gem, from which I got the following stack trace (but none of the lines are from my application code):
A NameError occurred in background at 2014-12-17 02:43:21 +0530 :
undefined method `error' for class `Class'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/performable_method.rb:7:in `method'
-------------------------------
Backtrace:
-------------------------------
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/performable_method.rb:7:in `method'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/performable_method.rb:7:in `method'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/backend/base.rb:113:in `hook'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/backend/base.rb:97:in `rescue in block in invoke_job'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/backend/base.rb:101:in `block in invoke_job'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/lifecycle.rb:61:in `call'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/lifecycle.rb:61:in `block in initialize'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/lifecycle.rb:66:in `call'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/lifecycle.rb:66:in `execute'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/lifecycle.rb:40:in `run_callbacks'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/backend/base.rb:91:in `invoke_job'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/worker.rb:199:in `block (2 levels) in run'
/home/ubuntu/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/timeout.rb:82:in `block in timeout'
/home/ubuntu/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/timeout.rb:70:in `catch'
/home/ubuntu/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/timeout.rb:70:in `timeout'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/worker.rb:199:in `block in run'
/home/ubuntu/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/benchmark.rb:294:in `realtime'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/worker.rb:198:in `run'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/worker.rb:275:in `block in reserve_and_run_one_job'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/lifecycle.rb:61:in `call'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/lifecycle.rb:61:in `block in initialize'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/lifecycle.rb:66:in `call'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/lifecycle.rb:66:in `execute'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/lifecycle.rb:40:in `run_callbacks'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/worker.rb:275:in `reserve_and_run_one_job'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/worker.rb:182:in `block in work_off'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/worker.rb:181:in `times'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/worker.rb:181:in `work_off'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/worker.rb:146:in `block (4 levels) in start'
/home/ubuntu/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/benchmark.rb:294:in `realtime'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/worker.rb:145:in `block (3 levels) in start'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/lifecycle.rb:61:in `call'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/lifecycle.rb:61:in `block in initialize'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/lifecycle.rb:66:in `call'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/lifecycle.rb:66:in `execute'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/lifecycle.rb:40:in `run_callbacks'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/worker.rb:144:in `block (2 levels) in start'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/worker.rb:143:in `loop'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/worker.rb:143:in `block in start'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/plugins/clear_locks.rb:7:in `call'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/plugins/clear_locks.rb:7:in `block (2 levels) in <class:ClearLocks>'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/lifecycle.rb:79:in `call'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/lifecycle.rb:79:in `block (2 levels) in add'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/lifecycle.rb:61:in `call'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/lifecycle.rb:61:in `block in initialize'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/lifecycle.rb:79:in `call'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/lifecycle.rb:79:in `block in add'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/lifecycle.rb:66:in `call'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/lifecycle.rb:66:in `execute'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/lifecycle.rb:40:in `run_callbacks'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/worker.rb:142:in `start'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/command.rb:124:in `run'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/command.rb:112:in `block in run_process'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/daemons-1.1.9/lib/daemons/application.rb:255:in `call'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/daemons-1.1.9/lib/daemons/application.rb:255:in `block in start_proc'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/daemons-1.1.9/lib/daemons/daemonize.rb:82:in `call'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/daemons-1.1.9/lib/daemons/daemonize.rb:82:in `call_as_daemon'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/daemons-1.1.9/lib/daemons/application.rb:259:in `start_proc'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/daemons-1.1.9/lib/daemons/application.rb:296:in `start'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/daemons-1.1.9/lib/daemons/controller.rb:70:in `run'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/daemons-1.1.9/lib/daemons.rb:197:in `block in run_proc'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/daemons-1.1.9/lib/daemons/cmdline.rb:109:in `call'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/daemons-1.1.9/lib/daemons/cmdline.rb:109:in `catch_exceptions'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/daemons-1.1.9/lib/daemons.rb:196:in `run_proc'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/command.rb:110:in `run_process'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/command.rb:91:in `block in daemonize'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/command.rb:89:in `times'
/home/ubuntu/.rvm/gems/ruby-2.1.0/gems/delayed_job-4.0.4/lib/delayed/command.rb:89:in `daemonize'
bin/delayed_job:5:in `<main>'
-------------------------------
Data:
-------------------------------
* data: {}
This seems to be a feature limitation in Delayed Job. Errors are not reported properly. The trace and error message is completely incorrect.
I debugged mine by looking at the rails production log. It was hard to find because there was no error while adding the task to delayed job i.e. I was getting a [INFO] tag instead of [ERROR] in logs.
I hope someone points out how to get proper and meaningful stack traces in case of failed Delayed Jobs.
As a footnote, my error was a real specific (and lame) one. My smtp settings in /config/environments/production.rb was incompatible my mailer so I was getting this error only in production.

Redis EXECABORT Transaction discarded because of previous errors. (Redis::CommandError)

I'm trying to push some jobs onto a Sidekiq queue, which up until now, worked just fine. The error only appears in production.
Stack trace:
2013-12-13T20:35:04Z 22616 TID-amwho INFO: Sidekiq client with redis options {}
/home/avishai/apps/XXX/shared/bundle/ruby/1.9.1/gems/redis-3.0.6/lib/redis/pipeline.rb:79:in `finish': EXECABORT Transaction discarded because of previous errors. (Redis::CommandError)
from /home/avishai/apps/XXX/shared/bundle/ruby/1.9.1/gems/redis-3.0.6/lib/redis/client.rb:121:in `block in call_pipeline'
from /home/avishai/apps/XXX/shared/bundle/ruby/1.9.1/gems/redis-3.0.6/lib/redis/client.rb:245:in `with_reconnect'
from /home/avishai/apps/XXX/shared/bundle/ruby/1.9.1/gems/redis-3.0.6/lib/redis/client.rb:119:in `call_pipeline'
from /home/avishai/apps/XXX/shared/bundle/ruby/1.9.1/gems/redis-3.0.6/lib/redis.rb:2093:in `block in multi'
from /home/avishai/apps/XXX/shared/bundle/ruby/1.9.1/gems/redis-3.0.6/lib/redis.rb:36:in `block in synchronize'
from /home/avishai/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
from /home/avishai/apps/XXX/shared/bundle/ruby/1.9.1/gems/redis-3.0.6/lib/redis.rb:36:in `synchronize'
from /home/avishai/apps/XXX/shared/bundle/ruby/1.9.1/gems/redis-3.0.6/lib/redis.rb:2085:in `multi'
from /home/avishai/apps/XXX/shared/bundle/ruby/1.9.1/gems/sidekiq-2.17.0/lib/sidekiq/client.rb:159:in `block in raw_push'
from /home/avishai/apps/XXX/shared/bundle/ruby/1.9.1/gems/connection_pool-1.2.0/lib/connection_pool.rb:55:in `with'
from /home/avishai/apps/XXX/shared/bundle/ruby/1.9.1/gems/sidekiq-2.17.0/lib/sidekiq.rb:67:in `redis'
from /home/avishai/apps/XXX/shared/bundle/ruby/1.9.1/gems/sidekiq-2.17.0/lib/sidekiq/client.rb:150:in `raw_push'
from /home/avishai/apps/XXX/shared/bundle/ruby/1.9.1/gems/sidekiq-2.17.0/lib/sidekiq/client.rb:50:in `push'
from /home/avishai/apps/XXX/shared/bundle/ruby/1.9.1/gems/sidekiq-2.17.0/lib/sidekiq/client.rb:98:in `push'
from /home/avishai/apps/XXX/shared/bundle/ruby/1.9.1/gems/sidekiq-2.17.0/lib/sidekiq/worker.rb:83:in `client_push'
from /home/avishai/apps/XXX/shared/bundle/ruby/1.9.1/gems/sidekiq-2.17.0/lib/sidekiq/worker.rb:40:in `perform_async'
from /home/avishai/apps/XXX/releases/20131213194843/lib/listings_feed/listings_feed_parser.rb:79:in `send_to_sidekiq'
from /home/avishai/apps/XXX/releases/20131213194843/lib/listings_feed/listings_feed_parser.rb:74:in `enqueue'
from /home/avishai/apps/XXX/releases/20131213194843/lib/listings_feed/parsers/listings.rb:235:in `block in parse'
from /home/avishai/apps/XXX/releases/20131213194843/lib/listings_feed/parsers/listings.rb:24:in `block (2 levels) in each_listing'
from /home/avishai/apps/XXX/shared/bundle/ruby/1.9.1/gems/nokogiri-1.6.0/lib/nokogiri/xml/reader.rb:107:in `each'
from /home/avishai/apps/XXX/releases/20131213194843/lib/listings_feed/parsers/listings.rb:22:in `block in each_listing'
from /home/avishai/apps/XXX/releases/20131213194843/lib/listings_feed/parsers/listings.rb:21:in `open'
from /home/avishai/apps/XXX/releases/20131213194843/lib/listings_feed/parsers/listings.rb:21:in `each_listing'
from /home/avishai/apps/XXX/releases/20131213194843/lib/listings_feed/parsers/listings.rb:36:in `parse'
from /home/avishai/apps/XXX/releases/20131213194843/lib/listings_feed/listings_feed.rb:153:in `process!'
from run_feed.rb:74:in `block in <main>'
from run_feed.rb:71:in `each'
from run_feed.rb:71:in `<main>'
I also encountered this error when hitting maxmemory on that redis instance.
You can test it on your dev box by setting maxmemory (ie.. in /usr/local/etc/redis.conf) to sthg small e.g.
maxmemory 3MB
Then fill up your redis with a bunch of data, start Sidekiq, and watch the fireworks
2014-02-03T14:32:30Z 59365 TID-ov2cb18yw WARN: {"retry"=>true, "queue"=>"default", "backtrace"=>true, "class"=>"MailWorker", "args"=>["Profile::Created", 868], "jid"=>"d7b0589736818c2ffcd58c90", "enqueued_at"=>1391437950.4245608}
2014-02-03T14:32:30Z 59365 TID-ov2cb18yw WARN: EXECABORT Transaction discarded because of previous errors.
2014-02-03T14:32:30Z 59365 TID-ov2cb18yw WARN: /usr/local/opt/rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/redis-3.0.4/lib/redis/pipeline.rb:76:in `finish'
/usr/local/opt/rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/redis-3.0.4/lib/redis/client.rb:121:in `block in call_pipeline'
/usr/local/opt/rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/redis-3.0.4/lib/redis/client.rb:243:in `with_reconnect'
/usr/local/opt/rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/redis-3.0.4/lib/redis/client.rb:119:in `call_pipeline'
/usr/local/opt/rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/redis-3.0.4/lib/redis.rb:2077:in `block in multi'
/usr/local/opt/rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/redis-3.0.4/lib/redis.rb:36:in `block in synchronize'
/usr/local/opt/rbenv/versions/1.9.3-p392/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/usr/local/opt/rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/redis-3.0.4/lib/redis.rb:36:in `synchronize'
/usr/local/opt/rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/redis-3.0.4/lib/redis.rb:2069:in `multi'
/usr/local/opt/rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/redis-namespace-1.3.1/lib/redis/namespace.rb:337:in `namespaced_block'
/usr/local/opt/rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/redis-namespace-1.3.1/lib/redis/namespace.rb:224:in `multi'
/usr/local/opt/rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/sidekiq-2.13.1/lib/sidekiq/processor.rb:93:in `block in stats'
/usr/local/opt/rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/connection_pool-1.1.0/lib/connection_pool.rb:49:in `with'
/usr/local/opt/rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/sidekiq-2.13.1/lib/sidekiq.rb:67:in `redis'
/usr/local/opt/rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/sidekiq-2.13.1/lib/sidekiq/util.rb:25:in `redis'
/usr/local/opt/rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/sidekiq-2.13.1/lib/sidekiq/processor.rb:92:in `stats'
/usr/local/opt/rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/sidekiq-2.13.1/lib/sidekiq/processor.rb:46:in `block in process'
/usr/local/opt/rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/celluloid-0.14.1/lib/celluloid/calls.rb:25:in `call'
/usr/local/opt/rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/celluloid-0.14.1/lib/celluloid/calls.rb:25:in `public_send'
/usr/local/opt/rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/celluloid-0.14.1/lib/celluloid/calls.rb:25:in `dispatch'
/usr/local/opt/rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/celluloid-0.14.1/lib/celluloid/calls.rb:67:in `dispatch'
/usr/local/opt/rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/celluloid-0.14.1/lib/celluloid/future.rb:15:in `block in new'
/usr/local/opt/rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/celluloid-0.14.1/lib/celluloid/internal_pool.rb:59:in `call'
/usr/local/opt/rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/celluloid-0.14.1/lib/celluloid/internal_pool.rb:59:in `block in create'
I resolved this by doing a FLUSHALL, which cleared out all the data from the redis instance. It appears that somewhere along the way the data got corrupted, and that fixed it.
Another possible reason is a broken master-slave replication. For example with min-slaves-to-write configuration option set:
127.0.0.1:6379> set foo 1
(error) NOREPLICAS Not enough good slaves to write.
To temporarily resolve just execute:
CONFIG SET min-slaves-to-write 0

Rails 3 + Daemons gem: Exception when querying model

As part of my rails project, we are going to use a daemon as a message queue listener to execute commands coming from a Rails RESTful webservice front end.
For ease of prototyping, we are using the Daemons gem to create a very simple daemon. Right now, it's super simple. Here is the code:
require 'rubygems'
require 'daemons'
require File.expand_path('../../config/environment', __FILE__)
Daemons.run_proc('aeon_server') do
loop do
empires = Empire.all
sleep(5)
end
end
Basically, it requires the things for daemons, then requires my Ruby environment, then launches in to the daemon. The daemon simply attempts to query everything from the Empires table. Then it sleeps and does it again.
When it goes to execute 'all', I get the following exception:
C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_support/buffered_logger.rb:109:in `write': closed stream (IOError)
from C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_support/buffered_logger.rb:109:in `block in flush'
from <internal:prelude>:10:in `synchronize'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_support/buffered_logger.rb:102:in `flush'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_support/buffered_logger.rb:126:in `auto_flush'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_support/buffered_logger.rb:67:in `add'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_support/buffered_logger.rb:78:in `debug'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.7/lib/active_record/connection_adapters/abstract_adapter.rb:206:in `rescue in log'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.7/lib/active_record/connection_adapters/abstract_adapter.rb:199:in `log'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.7/lib/active_record/connection_adapters/sqlite_adapter.rb:135:in `execute'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.7/lib/active_record/connection_adapters/sqlite_adapter.rb:284:in `select'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.7/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.7/lib/active_record/connection_adapters/abstract/query_cache.rb:56:in `select_all'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.7/lib/active_record/base.rb:468:in `find_by_sql'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.7/lib/active_record/relation.rb:64:in `to_a'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/activerecord-3.0.7/lib/active_record/relation/finder_methods.rb:143:in `all'
from C:in `all'
from script/aeon_server_control.rb:9:in `block (2 levels) in <main>'
from script/aeon_server_control.rb:7:in `loop'
from script/aeon_server_control.rb:7:in `block in <main>'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/daemons-1.1.3/lib/daemons/application.rb:249:in `call'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/daemons-1.1.3/lib/daemons/application.rb:249:in `block in start_proc'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/daemons-1.1.3/lib/daemons/application.rb:260:in `call'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/daemons-1.1.3/lib/daemons/application.rb:260:in `start_proc'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/daemons-1.1.3/lib/daemons/application.rb:293:in `start'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/daemons-1.1.3/lib/daemons/controller.rb:73:in `run'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/daemons-1.1.3/lib/daemons.rb:195:in `block in run_proc'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/daemons-1.1.3/lib/daemons/cmdline.rb:109:in `call'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/daemons-1.1.3/lib/daemons/cmdline.rb:109:in `catch_exceptions'
from C:/Ruby/lib/ruby/gems/1.9.1/gems/daemons-1.1.3/lib/daemons.rb:194:in `run_proc'
from script/aeon_server_control.rb:6:in `<main>'
Any idea why ActiveSupport is throwing this exception? Are there additional steps I need to "bootstrap" my rails environment in to the daemon, beyond just requiring the environment?
There're some intricacies with regard to file descriptors when the process is forked/spawned/whatever-it-is-called-on-windows.
Try to reinstantiate a logger after you do Daemons.run_proc('aeon_server') with Rails.logger = ActiveSupport::BufferedLogger.new('/path/to/log')

Resources