My terminal does not return to the usual command line prompt $ after I run rails server. If I open another Bash window everything works fine.
Should I just exit the first window, or will I interrupt some process?
Thanks for the advice!
If you run rails server or rails s, you wouldn't get that prompt. You need to press Ctrl-C to shutdown the server. That instruction is present is command shell itself (=> Ctrl-C to shutdown server).
(arup~>sample_app)$ rails s
=> Booting WEBrick
=> Rails 4.0.2 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2014-01-27 02:22:02] INFO WEBrick 1.3.1
[2014-01-27 02:22:02] INFO ruby 2.0.0 (2013-02-24) [i686-linux]
[2014-01-27 02:22:02] INFO WEBrick::HTTPServer#start: pid=11223
Now see below, what happened when I did press Ctrl-C :
(arup~>sample_app)$ rails s
=> Booting WEBrick
=> Rails 4.0.2 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2014-01-27 02:22:02] INFO WEBrick 1.3.1
[2014-01-27 02:22:02] INFO ruby 2.0.0 (2013-02-24) [i686-linux]
[2014-01-27 02:22:02] INFO WEBrick::HTTPServer#start: pid=11223 port=3000
^C[2014-01-27 02:24:59] INFO going to shutdown ...
[2014-01-27 02:24:59] INFO WEBrick::HTTPServer#start done.
Exiting
(arup~>sample_app)$
Yes when you use rails server or rails s the WEBrick server starts and keeps running it in the terminal tab you ran it on(till you interrupt it).
In Terminal Ctrl + C is used to kill/break/interrupt any process only
$ not showing means there is a process already running in that terminal and therefore you have to open a new terminal tab(Ctrl + Shift + T) and work there or break the existing ongoing process to get the $ and work in the present tab.
This also might help you out
http://help.codeschool.com/discussions/rails-for-zombies-2/225-after-i-enter-rails-server-on-the-command-line-the-command-line-doesnt-reappear
In other words you ideally can't or actually shouldn't use the terminal in which the server is running on, but anyways if you DO want to then this SO thread should help you
How to use same terminal window after using "rails server" command?
Hope you understood
use:
rails server -d
to start the server as daemon.
Related
I'm relatively new the coding world so apologies upfront if this is vague or i'm mis using some jargon...
I am trying to create a new application using Ruby on Rails. Having created the app, I went to run it on my local machine by typing rails server but it seems as though the server won't complete..any thoughts? I only get as far as the below and then nothing else materialises to indicate the server has successfully completed... I've tried shutting down the server and trying again but no luck
=> 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
[2017-04-29 15:58:45] INFO WEBrick 1.3.1
[2017-04-29 15:58:45] INFO ruby 2.3.1 (2016-04-26) [x86_64-darwin16]
[2017-04-29 15:58:45] INFO WEBrick::HTTPServer#start: pid=1493 port=3000
after running "rails server" on my mac to start my application, my terminal does not allow me to write commands in the terminal. All I get is the following, with the problem that I can not write any commands.
Last login: Mon Jan 2 13:19:07 on ttys001
Nicholass-MacBook-Pro:~ nicholaswenzel$ cd last_test
Nicholass-MacBook-Pro:last_test nicholaswenzel$ cd nofuckingidea
Nicholass-MacBook-Pro:nofuckingidea nicholaswenzel$ rails s
=> Booting WEBrick
=> Rails 4.2.6 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2017-01-02 13:23:18] INFO WEBrick 1.3.1
[2017-01-02 13:23:18] INFO ruby 2.2.3 (2015-08-18) [x86_64-darwin15]
[2017-01-02 13:23:18] INFO WEBrick::HTTPServer#start: pid=8743 port=3000
Can anyone help?
You can start your server in a background:
rails server &
But, usually, this problem can be resolving by starting an additional terminal process (open new terminal window or tab). In this case, you'll be able to see server logs in runtime.
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).
c:\mowes\www\rails_projects\first_app>rails s
=> Booting WEBrick
=> Rails 4.0.0 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2013-10-17 16:49:22] INFO WEBrick 1.3.1
[2013-10-17 16:49:22] INFO ruby 1.9.3 (2012-04-20) [i386-mingw32]
[2013-10-17 16:49:22] INFO WEBrick::HTTPServer#start: pid=11400 port=3000
When I go to 0.0.0.0:3000 I get this
I did not use RailsInstaller and am using a portable version of Ruby and Rails.
0.0.0.0 just means that it's listening on all addresses that the machine has. Try browsing to http://localhost:3000/ instead.
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.