I am using Nginx, passenger, and Rails. The rails app is caching responses for HTTP GET requests. Is there a way to disable this? If so, where and how do I do this?
The GET request returns the same response every time. When I run rails locally, without nginx or passenger, on development mode, I don't get this issue. It's only in the production environment that it returns the same response every time the call is made. If the server is reset, it returns a different value.
Generally it's a bad idea to disable caching, but if you want to so.
in rails app in production.rb file, set config.action_controller.perform_caching to false
Related
I'm running the Exception Notification gem on Rails 5. I have it setup the default way in config/environments/production.rb:
Rails.application.config.middleware.use ExceptionNotification::Rack,
email: {
# deliver_with: :deliver, # Rails >= 4.2.1 do not need this option since it defaults to :deliver_now
email_prefix: '[MFTA Error Notification] ',
sender_address: %{"notifier" <almost#got.me>},
exception_recipients: %w{butnotquite#gmail.com}
}
This works fine for standard errors when the site is up...
But shouldn't it send me a report on 500 server errors a well? Very randomly... about once a month or so... the rails app will crash on me and I'll need to redeploy it to get it to work again. But I won't even know that the site's down without a notification.
So is there some separate config... or even another Gem... to let me know when this happens?
Since your app is hosted in aws, you can setup a healthcheck endpoint in your app and use a lambda function to ping it periodically. If there’s no 200 response, its very likely your app is down as serving a healthcheck is a dead simple thing which shouldnt fail.
Normally people would set a threshold say X consecutive health check failure within Y duration to verify that the app is down. But this would require your lambda function to be stateful. If you dont mind getting false alarm due to say deployment or server restart, you can forget about this.
Also, if you want the health check to be more performant, you can just implement your rack middleware to intercept this healthcheck request and return a 200 response. In that sense teh request doesnt has to go through all the stacks until it reach Rails
I have a rails app on 2 servers and it uses a load balancer. The load balancer makes requests to /healthcheck every few seconds to make sure that the servers are still available. However, this is filling up my production logs. Is there a way to filter out requests to healthcheck#healthcheck ?
quiet_assets removes calls to your assets in development. I'm sure you could probably do something similar in production for healthchecks.
https://github.com/evrone/quiet_assets/blob/master/lib/quiet_assets.rb
I have inherited the maintenance of a legacy web-application with an "interesting" way to manage concurrent access to the database.
The application is based on ruby-on-rails 2.3.8.
I'd like to set up a development environment and from there have two web browser make simultaneous requests, just to get the gist of what is going on.
Of course this is not going to work if I use Webrick, since it services just one http request at a time, so all the requests are effectively serialized by it.
I thought that mongrel could help me, but
mongrel_rails start -n 5
is actually spawning a single process and it seems to be single-threaded, too.
What is the easiest way of setting my development environment so that it responds to more than one request at a time? I'd like to avoid using apache and mod_passenger because, this being development, I'd like to be able to change the code and have it reloaded automatically on the next request.
In development mode, mod_passenger does reload classes and views. I use passenger exclusively for both development and deployment.
In production, you can (from the root of the rails app):
touch tmp/restart.txt
and passenger will reload the app.
Take a look at thin
http://code.macournoyer.com/thin/
We have an environment running that uses Apache, Passenger and rails. The system is handling most request normally, yet certain requests do not make it to the rails application. For instance, a request to /books is successful, but /books/1 hits apache and passenger, but does not even make it to rails.
We set the apache log level to debug and the passenger log level to 3 so that we could monitor all incoming requests. We could see each request coming through and even the /books/1 request is being handled by passenger. But it never gets to rails.
Is there any way to determine where the request goes between Passenger and rails or where debugging information might live? Has anyone ever seen any problems with passenger spawning or queuing? We have spawning set to conservative. Also, we have had some permission/ownership problems in the past, so I am not ruling this out yet.
Thanks in advance
First guess: is that it's reading from your cache at public/books/1.html. This fits all the symptoms. If there is a public/books/1.html file when you go to request books/1 Apache will serve the request by sending just that file.
Second guess: alternate configuration is mucking about with how Apache is serving the route.
I'd like to know why is there a need to restart the server (Mongrel/WEBrick) every time a model file is updated? I know it doesn't get loaded in if you don't do it - but is there any documentation out there that would explain why it does so?
Thanks!
Development environments do not require you to restart the server if you change a model. They will reload the environment for each request if necessary.
Production environments are a different story. A Rails server (mongrel/passenger/webrick/etc) running in a production environment will only load your Rails environment once when the process is started. This takes a couple of seconds, as you might notice when starting the console which also loads your Rails environment. To avoid this overhead for each request the server will spawn a new thread from the loaded environment to handle each incoming request.
Because the server only responds to HTTP requests, and the usual signals. There's no good way to force an environment reload beyond always loading a fresh environment (like a development environment, or restarting the server.