I'm seeing some strange behavior when I run Rails server with rails s -e [env] (double ** added for emphasis):
~/app> rails s -e=**production**# << ok...v
=> Booting Mongrel # v huh?
=> Rails 3.1.1 application starting in **test** on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
^CExiting
~/app> rails s -e=**development**
=> Booting Mongrel
=> Rails 3.1.1 application starting in **test** on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
^CExiting
~/app> RAILS_ENV=**development** rails s
=> Booting Mongrel
=> Rails 3.1.1 application starting in **development** on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
^CExiting
~/app> RAILS_ENV=**production** rails s
=> Booting Mongrel
=> Rails 3.1.1 application starting in **production** on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
The upshot is that the -e switch is being ignored.
The Rails guide doesn't mention any situations where it will be overriden. The command line help says -e Specifies the environment to run this server under test/development/production). OK.
I really think this was working fine a few weeks ago (been a while since I started a prod server on that box) so I may have changed something that broke this, but what? I checked for places where I was using = instead of == but didn't find any. Don't think that would explain this.
Update: John correctly points out that it is -e [env]. I tried that first with the same results then tried -e=[env]. The correct way (still produces incorrect result):
~/app> rails s -e production -p 5000
=> Booting Mongrel ^^^^^^^^^ vvvv
=> Rails 3.1.1 application starting in test on http://0.0.0.0:5000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Check that you don't have the RAILS_ENV environment variable set as it will override whatever you pass as a command line option.
The relevant bit of the rails source ydoes this
ENV["RAILS_ENV"] ||= options[:environment]
options is populated from the command line arguments, so if RAILS_ENV is already set your command line options have no effect.
It's rails s -e <env>, not rails s -e=<env>. Notice the space between -e and the name of the environment:
#Ψ rails s -e production
#=> Booting WEBrick vvvvvvvvvv
#=> Rails 3.1.1 application starting in production on http://0.0.0.0:3000
^^^^^^^^^^
#Ψ rails s -e staging
#=> Booting WEBrick vvvvvvv
#=> Rails 3.1.1 application starting in staging on http://0.0.0.0:3000
^^^^^^^
Related
After running:
bundle exec rake assets:precompile RAILS_ENV="production"
I run rails s -e production but I am getting following error and server is not starting.
rails s -e production
=> Booting WEBrick
=> Rails 4.2.4 application starting in production on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server Exiting
C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/activesupport4.2.4/lib/active_support/dependencies.rb:274:in `require':
C:/Users/app/models/~$Meeting.rb:1: Invalid char `\x03' in expression (SyntaxError)> from
C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-
4.2.4/lib/active_support/dependencies.rb:274:in `block in require'from C:/RailsInstaller/Ruby2.2.0/lib/ruby/gems/2.2.0/gems/activesupport-
4.2.4/lib/active_support/dependencies.rb:240:in `load_dependency'
But running the application on development is working fine.
Join in my office the following command:
RAILS_ENV=production rails s production
And I get the following error:
/usr/local/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/handler.rb:78:in `require': cannot load such file -- rack/handler/production (LoadError)
Please, help!!
Run this command to run the rails server in production mode
rails s -e production
guessing:
RAILS_ENV=production rails s production
to:
RAILS_ENV=production rails s
Sure this is the problem of your command
RAILS_ENV=production rails s production
change it to:
RAILS_ENV=production rails s
usage of rails s command is :
Usage: rails server [mongrel, thin, etc] [options]
-p, --port=port Runs Rails on the specified port.
Default: 3000
-b, --binding=ip Binds Rails to the specified ip.
Default: 0.0.0.0
-c, --config=file Use custom rackup configuration file
-d, --daemon Make server run as a Daemon.
-u, --debugger Enable ruby-debugging for the server.
-e, --environment=name Specifies the environment to run this server under (test/development/production).
Default: development
-P, --pid=pid Specifies the PID file.
Default: tmp/pids/server.pid
-h, --help Show this help message.
so the word following rails s is expected to be server you want to run your application with i.e. (Thin, WEBrick, FastCGI, CGI, SCGI and LiteSpeed.)
rails s thin
=> Booting Thin
=> Rails 3.2.16 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
rails s WEBrick
=> Booting WEBrick
=> Rails 3.2.16 application starting in development on http://0.0.0.0:3000
=> Ctrl-C to shutdown server
It runs as local, and uses WEBrick 1.3.1 I want to run using apache + passenger + rails
BIt of a weird one this.
rails s
=> Booting Thin
=> Rails 3.2.13 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Thin web server (v1.6.2 codename Doc Brown)
Maximum connections set to 1024
Listening on 0.0.0.0:3000, CTRL+C to stop
But when I call
puts Rails.env
in a controller, it says
production
In rails console it correctly says development
Rails.env
=> "development"
Any ideas.
I want to run in dev locally and production on my server. Particularly important as I'm testing functionality where it costs me money to run certain api calls and I have them faked if Rails.env.prodcution? is false.
Running rails 3.2.13
I am new at RoR.
I've just installed RoR on my local computer,but I can't open localhost page with it.
After rails s command it showed to me this :
=> Booting WEBrick
=> Rails 3.2.13 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
A server is already running. Check /home/roma/Templates/first_app/tmp/pids/server.pid.
Exiting
What could be a problem?
Check if the same app is already running. If not, simply delete the file located at /home/roma/Templates/first_app/tmp/pids/server.pid.
run kill -15 $(cat tmp/pids/server.pid ) from inside your project, e.g:
cd /home/roma/Templates/first_app/
kill -15 $(cat tmp/pids/server.pid )
That would kill the rails server running
I am deploying a Rails application into production using Thin. Right after starting rails, Thin shuts down, the only ouput is 'Exiting':
$ bundle exec rails s -e production
=> Booting Thin
=> Rails 4.0.0 application starting in production on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
>> Thin web server (v1.5.1 codename Straight Razor)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:3000, CTRL+C to stop
Exiting
The same configuration / setup works in development. The same configuration works for production using WEBrick:
$ bundle exec rails s -e production
=> Booting WEBrick
=> Rails 4.0.0 application starting in production on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2013-07-19 17:59:07] INFO WEBrick 1.3.1
[2013-07-19 17:59:07] INFO ruby 2.0.0 (2013-06-27) [x86_64-linux]
[2013-07-19 17:59:07] INFO WEBrick::HTTPServer#start: pid=5231 port=3000
Surely it should be possible to receive some output on why it is shutting down from a web server rated for production use. However, I have not found out how.
Any ideas?
Turns out starting Thin in production mode made Rails eager load a module also using EventMachine, thus keeping the Thin code from being blocked after starting and immediately shutting down instead.