Terminal command rails server
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
Terminal won't allow me to enter command after rails server any answer please
Probably if you started your webrick, your server is now running and listening on http://localhost:3000
. To see it, simply open a browser and point to that address.
If you want to stop the server (and enter other commands) as you seem to want to do, press ctrl + c
to kill the server
Inputting Terminal Commands When Running a Rails Server
Usually you will just start a second Terminal window or tab and run the commands your book mentions in there. It will use the same database, but not the same process your server is running in.
Single custom terminal command to open multiple windows with different things inside
You can use tmux
for these kind of staff. For example the example below will create 5 windows(which are tabs), each named with the first parametr after -n
and then executed.
#!/bin/sh
tmux new-session -d -s hawkhost
tmux new-window -t hawkhost:1 -n 'vim' 'vim'
tmux new-window -t hawkhost:2 -n 'bundle' 'bundle exec guard'
tmux new-window -t hawkhost:3 -n 'rails1' 'rails console'
tmux new-window -t hawkhost:4 -n 'rails2' 'rails server'
tmux new-window -t hawkhost:5 -n 'irc' 'irsii'
tmux select-window -t hawkhost:1
tmux -2 attach-session -t hawkhost
Look here for more information about this:
http://blog.hawkhost.com/2010/07/02/tmux-%E2%80%93-the-terminal-multiplexer-part-2/#tmux-shell-scripting
In tmux panes
are arbitary windows, and windows
are actually tabs.
Rails Server is not finishing inside terminal
With programs run from the terminal, they will run there unless they stop or have a daemon option. When you press ctrl-c, the rails webbrick server stops, so of course localhost won't show anything.
When the server is sitting there, it's waiting for a user to visit the site. It won't render views, for example, unless there's a request to render views.
If you want to run the webserver while still using the same terminal window, you need to run rails s
as a daemon (background process). Instead, run the command as rails s -d
which will "detach" the server process.
On a side-note, why not open multiple terminal windows, if your operating system has a GUI/Window Manager. I normally keep three terminal windows open to run the server, make git commits, check rake routes
, etc.
Related Question: Running Webrick server in background?
Unpause a rails server that was paused in a different terminal window
You can not easily move a process to a new tty. The easiest solution would be to start it in a screen session, detach screen and then resume in the new terminal.
Related Topics
Export Content of a SQLite3 Table in CSV
How to Step Out of a Loop with Ruby Pry
Disable a Group of Tests in Rspec
Ruby Mixins: Extend and Include
Does Dependency Injection Exist in Rails
Can You Use Semicolons in Ruby
How to Fetch Linkedin User Data
How to Capitalize the First Letter in a String in Ruby
Ruby Convert Array into Function Arguments
How to Dump an Http Request from Within Sinatra
In Ruby, When Should You Use Self. in Your Classes