getting syntax error while running rails s -e production - ruby-on-rails

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.

Related

Puma rails server not starting in Daemon mode on EC-2

I want to run Rails application on EC2 machine. When my SSH session terminates the rails server shutdown. I want to run the rails server in the background. I used rails s -d command to run rails daemon mode.
But it seems like Puma is not started. This is the message I receive and after that process terminates.
Booting Puma
=> Rails 5.0.6 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
Usually when I run rails server I get
=> Booting Puma
=> Rails 5.0.6 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.11.0 (ruby 2.3.5-p376), codename: Love Song
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop
What is going wrong? Is puma server booting up but not starting?

Error Rails 4 console on staging or production

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

Running Rails S with a fresh new app returns ERR_EMPTY_RESPONSE

I am using Vagrant to start a Rails app, everything seems right but then, when I create a test app, run rails s and go to localhost:3000 I get a ERR_EMPTY_RESPONSE and nothing is loaded. I get the following output when running rails s:
vagrant#rails-dev-box:~/projects/NewAppName$ rails s
=> Booting WEBrick
=> Rails 4.2.3 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2015-08-20 11:45:45] INFO WEBrick 1.3.1
[2015-08-20 11:45:45] INFO ruby 2.2.1 (2015-02-26) [i686-linux]
[2015-08-20 11:45:45] INFO WEBrick::HTTPServer#start: pid=12075 port=3000
I already ran rake db:create && rake db:migrate, and created a controller for the root. Anyone has an idea of what can be happening? Thank you.
It's in localhost on vagrant, so you can't connect it.
Try rails s -b 0.0.0.0 and then connect to vagrant IP(192.168.50.4:3000, for example).

Thin webserver shuts down immediately after start (rails)

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.

what can cause `rails s` to ignore the -e switch?

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
^^^^^^^

Resources