Rails - Do we need to restart server everytime a change is made? - ruby-on-rails

I am running a Rails app (with Passenger in Apache) in production mode. When I make changes to a erb file and refresh the site in browser, changes are not reflected. I need to restart the server to see the change reflected. This is annoying.
What is the right way to make changes deploy automatically?

You should not be using the production mode as a "development" mode. If you are making changes regularly, you should test on development mode and then if no bugs are found, you should push your code to your production environment.

Yes, In the production mode without restart your server, your changes not reflect.
I faced similar issue and i resolved it by following way.
My website is used by Americans only, so i push the code at midnight of US timezone.
Before i restart, i checked there how many users are loggedin now? If no users found then i restart my server.
Above technique helped me a lot.

Related

How to clean RoR database yml cache?

I've just set out to creating my first RoR project, using MySQL. Obviously after the first visit to browser the site informed me about not being able to connect to the DB with the current settings. I've quickly updated them in the config/database.yml, however it still complained about the old settings.
Eventually, it updated and was working fine, but I'm sure there's a cache somewhere that could have been cleared to make this less of a nuisance.
I have commented it earlier, Now adding it to my answer ;)
It seems like you have not restarted the server after done the changes in database.yml. Because, database.yml is being loaded once at the time of server start-up. So please try with restarting your rails server.

Is it possible to reload production Rails 3 app with Thin?

I would like to reload production application running with Thin. I know there is development mode, but our app is so complicated it simply cannot run in the development mode (it is very slow and unusable as we are more-or-less enterprise integration app). And we are not able to upgrade to Rails 3.2 which improved development mode.
Is there any way of reloading configuration with Thin or do I need to restart everytime? If not, I will keep restarting everytime I need to change something on a production setup in our testing environment.
In your config/environments/production.rb file you could turn the caching settings to false in order to have it behave more like development. This will allow you to update models etc.. without needing to restart the server. You won't want to check that into source control though. This may negate your entire reason for using production environment to speed things up though.
For reloading environment or initializer configurations you must always restart the server whether in development mode or not.
I personally would just be running the development environment as thats the intent. I've work on a couple large enterprise apps, and not had development environment unable to run...
If performance is the issue there are a couple things you could try to speed things up:
1) try using active_reload which was the precursor for much of the Rails 3.2 performance improvements https://github.com/paneq/active_reload
2) you can look into precompiling your development assets if its the asset pipeline slowing things down

Deploy Rails App

I have been asked to make a few cosmetic changes to our production deployment. I have access to our linux box where I can see the files I need to change. I only need to change html.erb files, but when I add, for instance a simple <p> tag, it does not show up live.
I know I probably have to reset the server or redeploy the code, but I have no idea what to do.
Our production deployment is not fully live, so I am making changes on the fly (I know that this is not the best practice). Our app is running in a shared hosting environment for the moment.
I have seen threads where people use Capistrano to deploy but how? We do not currently use it.
Can anyone help?
Whenever you make changes in production files, you have to restart the server to see the changes.
In production environment cache_classes is set to true. One can disable it and changes will be reflected without restarting the server.
So to reflect the change restart the server.
thanks......
I found a good guide on the Capistrano github wiki and also used this guide # kris.me.uk about a complete rails setup, including the Capistrano deployment aspect. I used them when learning how to deploy rails apps effectively. They should tell you what you need to know to get a basic deployment setup up and running.
Just incase someone is looking for the answer:
When rails is in development mode it will automatically reload changed files. When in production I need to restart it.
I eventually found out that we use God (A proces monitoring framework for rails - link here).
I had to restart our app with the following command: 'god restart APP_NAME'
Hope that helps someone :)
I wrote a Capistrano // NGINX guide and posted it on my blog. It's 85% correct, and should help you understand the big picture of the server/Rails/SSH configurations.
http://westonplatter.com/blog/2012/08/19/rails-slash-nginx-rackspace-deployment/

How did this Ruby on Rails app get deployed?

I have a Ruby on Rails app running on my server, and I can't figure out how it was deployed (someone else set it up).
The app is located in /var/www/myapp. Before it was deployed, I had been able to go in there and make minor edits to the app. The person helping me out with RoR then "deployed" it. It was unclear what deploying actually did, since it points to the same database and is on the same server. However, I can no longer edit it (or at least, the files I am editing are not being pointed to by the server).
Any way to figure out how this thing was deployed so I can take it down to edit it? Or should I basically just start over?
Was it maybe running in development mode before, and now it's in production? When it's in development mode, all of the files are loaded on each request, so your changes show up immediately. In production mode, you have to restart the server to see your changes.

Why don't my views update?

I'm new to Ruby on Rails and am creating a test application. So far, it's working, but when I make some minor changes to my views, the page doesn't change.
My problem may be related to this question, but I'm not sure what is meant by setting the date and time in the VM. My code is on a remotely hosted server, so I assume it would use the system time of that machine.
Is there a caching issue here? What can I do about it?
If you don't have control over the server environment yourself (no shell access, etc.), you can set the following at the top of config/environment.rb:
ENV['RAILS_ENV'] = 'development'
Development doesn't cache much, so while it's slower it's much nicer to develop in.
You'll still need to restart your app after making changes to anything outside the app/ folder though (configs, plugins, etc.).
You need to restart your Rails app (or Apache if you are using Passenger) if you are in production mode!

Resources