Rails 5.1.7 Server Hangs On First Request - ruby-on-rails

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

Related

Webrick dies with illegal instruction 4

Ever since switching to Mac based RoR development, I occasionally see that Webrick dies after simply printing 'Illegal Instruction 4'.
OSX 10.7.2, 10.7.3 and now 10.7.4
ruby 1.9.2p290
rails 3.2.2, and various other version starting with 3.1
So far, it's been rather innocuous, I just hit the up arrow key, hit enter, and restart the server, and everything is fine.
I've noticed that immediately after adding a new file to the development environment will almost always cause this condition. But it has happened when I haven't recently added a new file. But it almost always happens immediately after some file change. Put another way, I don't think it's ever happened when I'm just testing stuff, it seems that some kind of filesystem change is required to trigger this.
Just now, it happened, but this time it seems to of wedged up Webrick in some way, and after restarting Webrick, it wouldn't respond, I had to reboot to clear the condition. So this is starting to look less innocuous, and more like a looming development productivity problem.
Any other Mac developers seeing this?
I encountered this problem after implementing a scope on one of my models
scope :list_only, lambda { show_on_list }
(where show_on_list is an instance method). After rewriting the method to
scope :list_only, where("SomeSQLHere")
(where I used SQL in SomeSQLHere) it worked fine. I realize this doesn't address what "Illegal Instruction 4" means, but maybe the problem stems from some bad scope?
Do you have similar problems using non-webrick app servers? I encourage developing with the same app server you deploy with, which in this case looks to be Passenger.

Memcache working in production but fails locally

I'm working on an app with a friend and I keep running into errors in my local environment but the app works online (using Heroku). I believe memcache is causing issues in my local environment. Here's what I've done so far:
Added the memcache add-on to my app in Heroku
Installed Homebrew on my machine
Installed memcache using Homebrew with brew install memcached
Then I've restarted my app and ran the memcache process with memcached -vv.
When I access the app it works fine. Then I'll create a record. This also works fine. Then on page reload - when the record is fetched from the cache, the entire app systematically fails. Below is the error I receive (although I'm not sure how much help it is)
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.empty?
The error(s) only point to code where memcache is used. A simple user action (i.e. buy a book from a company) triggers the error and once it occurs the entire app is broken (meaning any route leads to the same error). It seems as though its just not storing/fetching the item, which makes me think the app isn't hitting memcache at all...Is it possible I have to gem install something - even though this is working in the production environment and on another dev's machine?
I'm looking for any guidance with troubleshooting memcache. More specifically, has anyone ever run into issues with local vs. production environments in regards to memcache? Any suggestions? I've thought about removing memcache from the app on Heroku, then un-installing it on my computer and then redoing everything.
I know I'm being fairly vague here but I'm not exactly sure what code to post that would help.
Thank you for any help.
After much frustration I began retracing the steps I took to install and implement memcache on my local environment. It didn't make sense how it was working online and with my friend's environment but not mine. Eventually I ran bundle install and then restarted the app and ran a new memcached process and that fixed everything. I'm still a bit confused but I guess my Gemfile just wasn't updated (even though I could've sworn it was).
I use memached without any problems in my environmens, though I do not use Herouku. To access memcached, I have installed the Dalli gem from https://github.com/mperham/dalli
Using it is rather simple.
In the file environment.rb add:
DC = Dalli::Client.new('localhost:11211')
In the application I use
DC.get(key)
DC.delete(key)
DC.set(key,value)
You will first need to test if the keys you're setting are actually getting set or not. You can use Memcached via a Telnet interface to test this.

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?

Old ActionMailer templates being cached?

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.

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.

Resources