Delayed_job "Undefined method" in production. (Passenger, no RVM) - ruby-on-rails

I've seen this error pop up in other places, but my circumstances seem to be somewhat unique. I'm running delayed_job (2.1.4) on my production server, which is using nginx, passenger, ruby 1.9.2, and rails 3.0.10. It is not using RVM. My jobs were running fine until my last code deploy, and now they all fail, with this message in the log:
--- !ruby/struct:Delayed::PerformableMailer
object: !ruby/object:Class TemplateMailer
method_name: :send_email
#snip
{undefined method `send_email' for #<Class:0x00000007523e90>
I looked through similar answers here, and on delayed_job's wiki, but haven't been able to crack it.
Everything is running fine on a VM staging server that I set up, so what could the problem be in production?

make sure you don't have a setup_load_paths.rb in your config directory

Related

`<module:RailsSettings>': uninitialized constant ActiveSupport::CurrentAttributes when running rails server

I have a ROR application I'm trying to stand up locally on a windows machine. Since it requires passenger I am using WSL2 to run Ubuntu. I've installed ruby (2.6.5) and made sure rails in installed (4.2.11.3). I've run bundle install successfully, but every time I try to run a command such as rails server, rake, ect. I get an error saying uninitialized constant ActiveSupport::CurrentAttributes. From googling, there isn't really one answer for this. I've tried removing and re-installing rails. Removed railties as well, but the error keeps happening. My suspicion is that it has something to do with me running on WSL2, but I am not sure.

Any way to run byebug under passenger + nginx?

I developed a simple rails app which works in development environment under WEBrick. However, when I move to production environment it doesn't work. I fixed trivial errors relating to assets and things. However, some things just don't work. It would be extremely helpful to be able to see what is going on interactively with debugger.
I can insert byebug in the code, and it pauses code from running, but since neither passenger nor nginx logs to STDOUT (by default) I can't get to the byebug prompt. (and neither read STDIN)
Is there a way to run byebug under passenger + nginx?
Edit
This time my issue was related to https.
Passenger author here. Byebug integration is available in Passenger Enterprise: https://www.phusionpassenger.com/library/admin/nginx/debugging_console/ruby/
You can use https://github.com/davejamesmiller/ruby-debug-passenger
This adds a rake task, just run 'rake debug' and you'll be connected to your code at the point where it hits byebug

Rails 3.2.1 logging in Passenger, Thin, or Unicorn

I've tried those 3 hosting approaches for my Rails app, and no matter what I do, I can't get consistant logging when I run in the production environment.
For my tests, I created a blank app and tried to access the root directory. I would then add a users scaffold and rake the database.
If I turn RAILS_ENV to development, the log/devlopment.log works just fine, logging everything that I would expect.
When I turn RAILS_ENV to production, the log/production.log logs in a strange manner. In Passenger, I get the first routing error. Then nothing. When I restarted apache or nginx, I would get all the routing errors that I had caused since the first (logged) one, then the log would fail to write anything new until I restarted the underlying server. apache2/error.log would get logged to if I had a configuration issue. Then it only logged cache misses
With Thin and Unicorn, I only get errors about the static assets (I did not precompile the assets). Once I precompiled the assets, no more log messages appeared.
On all 3 setups, I would get precompilation messages (when I ran assets:precompile) in production.log (indicating that Rails could at least write to the log).
Does anyone have a Rails 3.2.1 app that is running on one of the deployment gems (Passenger, Thin, or Unicorn), that is logging correctly in production mode? I've spent 5 days working on this. I'm out of ideas.
Turns out its a reported issue in Rails 3.2.x. A fix has been submitted and will hopefully be released with Rails 3.2.2.
https://github.com/rails/rails/issues/4277

Curl::Err::HostResolutionError (Couldn't resolve host name)

I'm running Rails 3.0 with a custom Devise authentication strategy that makes an SSL call using Curb. I get an "Curl::Err::HostResolutionError (Couldn't resolve host name)" error. Works fine manually from the command line.
The production environment is Apache running Passenger standalone with rvm 1.9.2#rails3, because the main Passenger is running ruby 1.8.7 and rails 2.3.4. I don't get this error with the my other app running the earlier versions of ruby and rails. Same code, but the difference seems to be Devise.
I've read elsewhere that this might have something to do with DNS and Apache, but I can't for the life of me figure this out and I'm really grasping at straws here. Any ideas would be greatly appreciated! Thanks in advance!
The issue actually turned out to be related to user permissions. When I ssh in with my user account and start Passenger standalone, no problem. When I start it remotely from Capistrano with the deploy user I get the error.

Rails authenticate_or_request_with_http_basic not working on SSL + Nginx

I've get an action in my Rails 3 app that I'm pw-protecting with authenticate_or_request_with_http_basic. Working fine on my development machine but it's not prompting for the http_basic user/password on the production server.
The entire production app runs over https/SSL on nginx.
Where do I look to resolve this? Does http basic auth not work over SSL? Or is there an nginx setting I need to look at?
TIA
Not sure if this related to Rails 3.
I just recently had problems running Mongrel 1.1.5 and Rails 2.3.8
Apparently, there is a bug in this set up where our production machine does not prompt for the user name and password (but works locally, because we are using web-brick).
In the mongrel.log we keep getting this error:
Error calling Dispatcher.dispatch #split' called for nil
:NilClass>
/usr/local/rvm/gems/ruby-1.8.7-p174/gems/actionpack-2.3.8/lib/action_controller/cgi_process.rb:52:indispatch_cgi'
/usr/local/rvm/gems/ruby-1.8.7-p174/gems/actionpack-2.3.8/lib/action_controller/dispatcher.rb:101:in `dispatch_cgi'
...
Found the monkey patch needed to fix this Mongrel 1.1.5 and Rails 2.3.8 and it worked for me.
The german site that lead to the solution: http://railssprech.de/ with 2 links for 2.3.8 and 2.3.9.
Here is the 2.3.8 version: http://www.pcoder.net/error-calling-dispatcher-dispatch/#axzz1RknBQso2
The patch explains why this error was occurring. Check the Rails 3 CGIHandler.dispatch_cgi method and see if it the same bug. You may need to extract the Rails 3 out and monkey patch it.
Hope this helps.
BTW: Mongrel 1.1.5 and Rails 2.3.5 works!

Resources