Old ActionMailer templates being cached? - ruby-on-rails

We're running a Rails 3.0.7 app with Passenger standalone + nginx and with ruby 1.9.2-p290, and we're seeing the strangest thing happen: After deploying some updates to a mailer template, new mails coming from the app sometimes have the updates applied, and sometimes the old template is being used.
I can't find anything about cached ActiomMailer templates online, and running rake tmp:cache:clear does not address the issue either, fwiw.
Has anyone ever experienced such a thing? Is there a definitive solution for this problem?
thanks,
Jacob

I've run into similar situations in our application, and we use Resque.
If I'm changing anything regarding mailers (which the Resque workers handle), I need to restart the workers.
Kill the workers and respawn them, it sounds like some of them might have the old environment loaded and others do not.

I was having this issue as well, although I wasn't using Resque to send mail. After staring at the offending templates for a while, I realized some of my inline CSS was incorrectly formatted (improper font-family and padding declarations) and that the template may have been ignoring everything else next to those declarations. As a result, it looked like it was pulling the old templates rather than rendering the new rules. Not sure if this is documented anywhere..
So, basically, I was lazy and it cost me a few hours of the day.

Related

Reverse Proxy with Heroku (for Wordpress) won't show full pages

I am trying to use a reverse proxy to serve a Wordpress blog running on EC2 at /blog from a rails app running on Heroku. I've used the rack-reverse-proxy gem and followed directions like this:
How can I use a subdirectory instead of a subdomain?
My app is running at http://myapp.com, my main target (wordpress) server is running at http://ec2-xx-xx-xx-xx.us-west-2.compute.amazonaws.com.
The pages on the target server all serve up fine when accessed directly. However, no matter what page I try to get through the reverse proxy, the HTML gets cut off. I've tried serving via both my own custom builds of Wordpress on Ubuntu (EC2) and on hosted examples like Bluehost. I've tried to access simple, handmade HTML and text test files, as well as the php files automatically generated by wordpress. Every time, the file is cut off.
Text files just get randomly cut off after ~1000 characters (this is variable)
Ditto for hand-coded HTML files
Wordpress files seem to get cutoff during the <head> (often mid-word) and render an empty <body>.
If a page should exist (e.g. http://ec2-xx-xx-xx-xx.us-west-2.compute.amazonaws.com/test-post, it will load (at least partially) at myapp.com/blog/test-post, so I don't know that rewrites are the issue.
I've tried enough variables on the wordpress/destination server that I'm inclined to think it's something on the Rails side (I have the same issue whether running "myapp" locally or on a Heroku test server). Beyond that, I'm stuck.
Any thoughts as to what I might be doing wrong? There's nothing in the Apache logs to indicate that anything is getting cut off. I'm pounding my head over this to no avail, and would really appreciate any help.
FIXED IT!
Digging into the rack-reverse-proxy gem, I found that I'm not the only person that had an issue with this:
Seeing some issues with Content-Length being corrupted, this ensures it matches body length as delivered.
The fix hasn't been merged into the master branch, but I forked my own copy, applied the fix, and it's working great. Hopefully it'll be merged into the master and nobody else will have to worry about this.
EDIT
One more thing that might be helpful for somebody else, if they are having problems with Visual Editing Mode not working under wordpress: Make sure that you also include this update to have the headers get passed in properly. The gem just hasn't really been updated in a couple of years, so it's up to you to go through and copy in fixes from other people. Applying those two fixes has everything working fine for me with a Heroku app/AWS&Ubuntu Wordpress setup.
Heroku will cut the request after a certain amount of time which would cause the behavior that you're seeing.
You basically have to pull the page from the wordpress blog and reserve it via Rack in the time for one request - think that could be the problem?

Getting Whenever to Work with RVM and Capistrano

I'm deploying an app that uses capistrano/whenever/rvm. Apparently, the whenever/rvm combo has a gotcha, as documented here. The wiki describes three ways of overcoming this. I've tried all of them and to no avail. These solutions include setting rvm_trust_rvmrcs_flag=1 in ~/.rvmrc, configuring schedule.rb to use the proper capistrano route, and using an alternative whenever gem. Again, none of these solutions have worked for me.
Checking crontab -e, whenever is successfully creating the cron jobs. According to the system logs, they're even being executed. However, they're not actually running in Rails. One debugging task reads like this:
every 1.minute do
runner "Company::Category.create(name: 'Shoe Cleaning')"
end
However, no Company::Category is created. Any advice for better debugging this? I've been on it for nearly 7 hours now and I'm struggling to move forward.

Rails server running in command prompt causing conhost.exe to crash

I have a Rails application that requires a bunch of environment stuff to get set up, and right now the easiest way for me to do it is to run a batch file to configure the environment and then launch the server from the command prompt. (Perhaps one day I will bite the bullet and transcribe all of the various environment variables into the project config, but I'd rather not...)
But when I do this, I occasionally manage to crash conhost.exe! It does not seem like I should be able to do this. Stranger still, it seems to happen most often if I access certain records in the application. I can't imagine it could crash if there were too much console output???
I am also having mscvrt-ruby.dll crashes, although I may have resolved those by doing some gem finagling. The conhost issue may or may not be related, I'm not sure. But if I launch the server from within RadRails, I don't seem to get these issues (the app doesn't completely work because of the missing environment stuff, but it seems much more stable).
Technicals: Windows 7, Rails 2.3.5, Ruby 1.93, Mongrel 1.2.0pre, uh, not sure what else...
Thoughts?

Newbie help with Rails/Ruby. Totally lost! (Mongrel related, I think) 503 Errors

I am on the verge of actually hiring someone to fix this
for me, but I hope it doesn't come to that.
I have no experience with Rails/Ruby, but I do know my way around
computers in general.
I have two domains on one server (Hostingrails, I am beginning to hate
them more and more these days).
My secondary domain works 100% fine.
But for the past few days, my primary domain has not been working, it
has been giving me 503 Errors. I've opened a ticket regarding this, and
they told me to SSH into my server and reset "Mongrel". I've done this
using the code they gave me; "mongrel_rails start -d -e production
-p13930"
It seemed to have worked, but the problem was still there. The log says
the error is something about:
"require': no such file to load -- dispatcher (LoadError)"
I've re-opened a ticket concerning this, and Hostingrails basically told
me that it is not their problem anymore and that it's solely up to me to
fix it. Brilliant.
So I spent a good part of the day looking and changing things around
through SSH (probably wasn't the greatest idea) but I still keep getting
503'd on my website.
However, I recently found out that my index file HAS to be index.html,
or it will not render the page. index.htm or index.php will result in a
503. If I set the index page to index.html, it worked. Which is strange,
my htaccess file allowed for all.
Another problem, I think I have inadvertently changed something in my
settings while I was SSH'd in. When I do "bundle install" it installs
the gems into my own private webspace, for example /home/mywebsite. But
I believe on my shared plan, all the rails/ruby/gems etc are all under
/usr/local/rvm/gems/ruby-1.9.2-p0/ which I don't think I have access to.
How do I change the directory to the default one? For example, before
the error log said:
/usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in
`require': no such file to load -- dispatcher (LoadError)
Now it says:
/home/mysite/.gems/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in
`require': no such file to load -- dispatcher (LoadError)
I think that's everything for now. Here are the rails installed on my
server by the host:
Installed at (3.0.0): /usr/local/rvm/gems/ruby-1.9.2-p0
(2.3.8): /usr/local/rvm/gems/ruby-1.9.2-p0
(again, I think my mongrel is looking in the wrong place, as my gems are
now being installed into /home/mywebsite/ instead of
/usr/local/rvm/gems/) Is it possible to someone reset the settings I've
changed back into my host's default one?
Would anyone be willing to take the time and try and fix this with me? I
am pretty annoyed at Hostingrails, since I didn't do anything to create
this problem, and they are outright refusing to help me. Why is my
primary domain getting 503 errors when my secondary domain works fine?
Mongrel is not compatible to ruby 1.9.2. You need use a fork of mongrel to use it https://github.com/kyusik/mongrel_cluster
I advice you to user thin/passenger or unicorn instead of mongrel.
I found a little blog post about problem with Mongrel and ruby 1.9.2 http://xaop.com/blog/2010/08/04/deploying-rails-3-on-ruby-1-9-2/
Maybe you could try using Ruby 1.8.7 - it causes less trouble in general at this time.
Not an answer to your question in particular, but if you're new to Ruby and Rails, then hosting your own stuff can be a daunting task.
Instead, try Heroku - simply push your Rails app to Heroku with git and you're good to go. They support custom domainnames for free.

Rails 5.1.7 Server Hangs On First Request

We are trying to update a Rails Server to release 5.1.
Server starts fine; but on the first request, goes completely dead; and has to be killed with signal 9.
Doesn't matter if its Puma or Webrick.
Doesn't matter if its 5.1.0 or 5.1.7
Doesn't matter if its development or production mode.
Eventually I saw the process size was 90GB and growing!
I've tried rbtrace, but struggled to get anything meaningful out of it.
I'm on osx, so strace isn't available, and I've struggled to get dtrace or dtruss to work, or produce anything meaningful.
So looking for a way to get this rails server to tell me what it's problem is....
Let me know what additional information is salient.
After quite a long process, I found a solution that didn't so much find the source of the issue, but provided a process to work around it.
First off, I used
rails app:update
And accepted all of the overwrites. Then using git, I walked through all of the removed code from my config file and returned just the required sections [like config/routes.rb, and ActionMailer config, for example].
Application then started right up, no issue.
This also led me to
http://railsdiff.org/5.0.7.2/5.1.0
Which is pretty critical for Rails upgrading. This is well worth consuming:
https://github.com/rails/rails/issues/31377#issuecomment-350422347

Resources