At the moment, when I start my postgres server (after a configuration change, e.g.), my rails app goes bonkers with FATAL errors while the server is restarting.
Instead of throwing an error, i'd like my rails app to wait for 5 seconds for the box to come back up. Is there a way to make that happen?
I'm using Rails 4.1 and Postgres 9.3.
I added pgbouncer between my postgresql server and the app. pgbouncer allows me to pause connections while I restart the postgresql server and resume the connections when the server comes back up.
Related
I have a Rails 4.2 app running on Heroku. Occasionally there is an issue that causes most incoming requests to get a server error. For example, there could be a memory leak or a max database connection issue. How can I setup a script or service to automatically restart the server when it detects errors?
I think this service could ping the app every few minutes and if it detects an error, it should confirm there's really a problem and then run heroku restart. How could this be set up?
After Googling this topic, I came across Neptune.io, which seems to provide a useful service for this task.
I have Rails 3 app on server.
It works just fine, but pretty often fails to boot.
I have tried to run tmp/restart.txt to restart Phusion Passanger server, but there is no change at all. It can be even half-hour to finally get access to my app.
I reviewed my log files, but there is no sign off any errors ore something other that could cause such major delay.
I tried to test my app using New Relic but even there was no succes to actually connect my site, with no errors at all.
Try using passenger-config restart-app to force Phuson Passenger to restart your app.
I am new to Ruby on Rails, but I managed to install it using the RailsInstaller and I am using Aptana Studio 3 as a text editor. I am on a Windows 7 x64.
Last week I managed to create a simple Hello world project, and it worked as it should when starting and stopping the rails server. To start the server I used the command rails server and to stop it I used CTRL+C.
Somehow, this week, when I'm trying to start the server it says "A server is already running". But, when I go to the correct page in a web browser it doesn't work. I get the error "Google Chrome could not connect to localhost:3010". So, this makes it seem like the server is not working, even though it supposedly is running.
So, I then try to stop the server from running, but CTRL+C doesn't seem to do anything. It doesn't give any kind of message at all when I input that, it just skips to a new line in the terminal window.
the standard port is 3000.
You can kill the server in the task manager and start it from new..
There is probably a rails process still running but bugged out/crashed. Try looking at the processes in the windows task manager to for a rails process, and cancel it. Additionally you can start a rails process on a different port with rails server -p PORT
So, i have a big rails application that is using delayed_job to send emails and SMS to the users.
Once in a while, the delayed_job process will simply stop working without any message on the logs. I have finally pinpointed the problem as the delayed_job process crashs when it coulnd't connect to the database.
Is there any configuration i can make so it will retry the connection instead of just crashing? I've tried setting the reconnect: true on the database.yml file with no success.
Another option that i'm looking for is maybe using a monitoring tool like god or bluepill.
Try using the -m flag when you start delayed job - that should start a separate monitor process that in my experience has been very good about restarting the process.
Im having a lot of latency running webrick on my development machine (localhost) .Anytime the browser makes a request, it takes the server about 8-9 seconds before it shows contents of the database, which contains just 34000 listings of text, output to the browser window.
I want to trouble shoot to find out whats happening.
Where should I start the process of troubleshooting?
I thought the first thing would be to monitor the web server logs to see requests.
But where can I find these on my development machine?
I know I can find the apache logs on my machine at
/var/log/apache2/access_log
but Rails doesnt run apache right? It runs webrick on port 3000
Please help.
When you run rails in development mode like:
rails s
..it usually runs WEBrick automatically as a foreground process and prints the type of information you're looking for to the console for each client request. You can check/tune some of the logging parameters by editing:
config/environments/development.rb
As WEBrick is the default web server, Apache has nothing to do with it unless you've configured your environment to do so. As you mentioned, the default port is 3000.
Newer versions of Rails can also log the the database query plan automatically for queries taking a long time to return.
# Log the query plan for queries taking more than this (works
# with SQLite, MySQL, and PostgreSQL)
config.active_record.auto_explain_threshold_in_seconds = 0.5
You should also check your specific database for proper indexing based on the schema and queries you're trying to optimize.