Can't quit server in Rails 3

After Rails 3 was just released today, I downloaded it and followed
the instructions on Rails Guide for building my first app at Getting
Started with Rails http://guides.rubyonrails.org/getting_started.html

Everything worked fine until I got to 4.2 Say "Hello" Rails. Entered
the "rails generate home controller index" command, and nothing
happened. When I hit Command-C to quit the server, nothing happened
either.

No error messages.

What happened?

Just wanted to append some more information.

Looks like after the rails server starts, it doesn't hand control back
to bash in the terminal. Say this because the normal prompt signs
don't show up in bash. So the question becomes why doesn't it hand
control back to bash, and how can this be changed?

Thank you.

Well, some questions came up after read through your post.

  1. Have you input “rails s” or “rails server” at your bash? I mean have you started your rails server yet?

  2. What do you mean when you generate home controller, nothing happens? No error message in terminal and in browser?

  3. Maybe it’s your typo, but shouldn’t it be “rails generate controller home index” not “rails generate home controller index”?

Hi--

My answers below.

> Just wanted to append some more information.

> Looks like after the rails server starts, it doesn't hand control back
> to bash in the terminal. Say this because the normal prompt signs
> don't show up in bash. So the question becomes why doesn't it hand
> control back to bash, and how can this be changed?

> Thank you.

> > After Rails 3 was just released today, I downloaded it and followed
> > the instructions on Rails Guide for building my first app at Getting
> > Started with Railshttp://guides.rubyonrails.org/getting_started.html

> > Everything worked fine until I got to 4.2 Say "Hello" Rails. Entered
> > the "rails generate home controller index" command, and nothing
> > happened. When I hit Command-C to quit the server, nothing happened
> > either.

> > No error messages.

> > What happened?

Well, some questions came up after read through your post.
1. Have you input "rails s" or "rails server" at your bash? I mean have you
started your rails server yet?

-- Yes, I have started the server with the "rails server" command.
Starts up OK, and can see the index page on http://localhost:3000 OK.

2. What do you mean when you generate home controller, nothing happens? No
error message in terminal and in browser?

-- There is no response at all.

3. Maybe it's your typo, but shouldn't it be "rails generate controller home
index" not "rails generate home controller index"?

-- Yes, that is my typo. Thank you for pointing it out. Have pasted in
the output from Terminal below.

Paul-Denlingers-MacBook-Pro:Sites pdenlinger$ cd blog3
Paul-Denlingers-MacBook-Pro:blog3 pdenlinger$ mate .
Paul-Denlingers-MacBook-Pro:blog3 pdenlinger$ rails server
/Library/Ruby/Gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:134:
warning: Insecure world writable dir /Library/Ruby/Gems/1.8 in PATH,
mode 040777
=> Booting WEBrick
=> Rails 3.0.0 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2010-08-30 11:09:58] INFO WEBrick 1.3.1
[2010-08-30 11:09:58] INFO ruby 1.8.7 (2009-06-12) [universal-
darwin10.0]
[2010-08-30 11:09:58] INFO WEBrick::HTTPServer#start: pid=9853
port=3000
rails generate controller home index

Thanks!

To quit the server try control + Break as an alternative!

Well then what happens after you “rails generate controller home index”

And visit http://localhost:3000/home/index ?

When I hit Command-C to quit the server, nothing happened
either.

Try control + c. That'll do donkey. That'll do.

If that doesn't work, you could always do the following (assuming you
don't have 'pkill' installed):

ps aux | grep rails | awk '{print $2}' | xargs kill -9

If you want to shorten that to "kill_rails" you could do the
following, restart your terminal, and always 'kill rails' efficiently:

echo "alias kill_rails='ps aux | grep rails | awk '{print $2}' |
xargs kill -9'" >> ~/.bashrc

The cool thing about stopping processes with a Mac is: there is more
than one way to kill a daemon.

Chris

Here is what I have been getting:

Paul-Denlingers-MacBook-Pro:blog3 pdenlinger$ rails server
/Library/Ruby/Gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:134:
warning: Insecure world writable dir /Library/Ruby/Gems/1.8 in PATH,
mode 040777
=> Booting WEBrick
=> Rails 3.0.0 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2010-08-30 17:05:33] INFO WEBrick 1.3.1
[2010-08-30 17:05:33] INFO ruby 1.8.7 (2009-06-12) [universal-
darwin10.0]
[2010-08-30 17:05:33] INFO WEBrick::HTTPServer#start: pid=10572
port=3000

Started GET "/home/index" for 127.0.0.1 at Mon Aug 30 17:06:40 +0800
2010

ActionController::RoutingError (No route matches "/home/index"):

Rendered /Library/Ruby/Gems/1.8/gems/actionpack-3.0.0/lib/
action_dispatch/middleware/templates/rescues/routing_error.erb within
rescues/layout (0.9ms)

Thanks for the detailed kill instructions; but it still doesn't work.
See terminal below:

Paul-Denlingers-MacBook-Pro:blog3 pdenlinger$ rails server
/Library/Ruby/Gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:134:
warning: Insecure world writable dir /Library/Ruby/Gems/1.8 in PATH,
mode 040777
=> Booting WEBrick
=> Rails 3.0.0 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2010-08-30 19:56:21] INFO WEBrick 1.3.1
[2010-08-30 19:56:21] INFO ruby 1.8.7 (2009-06-12) [universal-
darwin10.0]
[2010-08-30 19:56:21] INFO WEBrick::HTTPServer#start: pid=42417
port=3000
pkill
ps aux | grep rails | awk '{print $2}' | xargs kill -9
ps aux|grep rails|awk'{print$2}'|xargs kill -9

Started GET "/home/index" for 127.0.0.1 at Mon Aug 30 19:59:23 +0800
2010

ActionController::RoutingError (No route matches "/home/index"):

Rendered /Library/Ruby/Gems/1.8/gems/actionpack-3.0.0/lib/
action_dispatch/middleware/templates/rescues/routing_error.erb within
rescues/layout (1.0ms)
Paul-Denlingers-MacBook-Pro:blog3 pdenlinger$ rails server
/Library/Ruby/Gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:134:
warning: Insecure world writable dir /Library/Ruby/Gems/1.8 in PATH,
mode 040777
=> Booting WEBrick
=> Rails 3.0.0 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2010-08-30 19:56:21] INFO WEBrick 1.3.1
[2010-08-30 19:56:21] INFO ruby 1.8.7 (2009-06-12) [universal-
darwin10.0]
[2010-08-30 19:56:21] INFO WEBrick::HTTPServer#start: pid=42417
port=3000
pkill
ps aux | grep rails | awk '{print $2}' | xargs kill -9

Don't see how the server seemed to boot up again all by itself.

Is it possible to remove Ruby and Rails and do a clean install?

Paul Denlinger

<snip>

It looks like you're trying to type shell commands directly into the server output. This won't work.

The server runs in the foreground. You can't type commands into it. All you can do is quit it, by hitting Ctrl-C (not Command-C). It may take a few seconds to notice your signal and respond.

If you want to run shell commands while the server is running, open a new, separate terminal window. You can type shell commands into the new window, while leaving the server running in the original window. You need to have two terminal windows open.

Chris

Thank you, you caught my dumb newbie mistake.

Thanks to all of your for your time and help.

Paul Denlinger