Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I run the Ruby on Rails console in production without executing Spring?

Every time I run rails console on my production server, spring starts and I forget to stop it.. and some of my RAM goes away...

Is there some way to prevent Spring from starting in a production environment?

like image 252
Samuel G. P. Avatar asked Dec 16 '15 16:12

Samuel G. P.


People also ask

How do I disable Springs in rails?

To stop spring you can use bin/spring stop . It should start automatically when you run rails commands.

What is spring in Ruby on Rails?

Spring is a Rails application preloader that speeds up development by keeping your application running in the background. This means you that don't need to restart a server when you make changes. In RubyMine, Spring can be used to run Rails generators, tests, and Rake tasks.


2 Answers

I found it. You need to set the environment variable DISABLE_SPRING to true when executing the console, like this:

DISABLE_SPRING=true rails console

That way the Spring server will not load.

To do this automatically, you can export this variable in your .bashrc, .tcshrc, .zshrc appending this code to it:

export DISABLE_SPRING=true

and then loading it, in my case (I'm using zsh):

source ~/.zshrc

Reference:

https://github.com/rails/spring

http://www.cyberciti.biz/faq/linux-unix-shell-export-command/

like image 73
Samuel G. P. Avatar answered Oct 12 '22 12:10

Samuel G. P.


Put springin your testing group in the Gemfile:

gem "spring", group: :test

or

group :test do
 gem 'spring'
end
like image 2
thefabbulus Avatar answered Oct 12 '22 12:10

thefabbulus