24

I am currently in the process of learning Ruby on Rails. I have been following the Learning Rails podcast and screencasts.

I've run into a problem, well more of an annoyance. Every time the screencast has me kill the mongrel server I am forced to close the console window because CTRL+C isnt killing it as it should. I then have to open a new console window, navigate to my rails app and issue a 'ruby script/server' command to restart it.

What I am looking for is possibly a reason for this, a way to fix it or other suggestions to make this process faster and/or less annoying. Or even possibly a batch file or shortcut to open a cmd window right to where I need it?

John Topley
  • 113,588
  • 46
  • 195
  • 237
Jayrox
  • 4,335
  • 4
  • 40
  • 43

9 Answers9

40

Use Ctrl+Pause/Break instead. It will stop the server.

enter image description here

complex857
  • 20,425
  • 6
  • 51
  • 54
  • I ran into this problem too. Ctrl+Pause/Break worked wonderfully. This seems to be a new issue with rails 2.3.2. I just upgraded from 2.1.1. If I change my environment to 2.3.2 Ctrl+C doesn't work, change it back to 2.2.2, works great. – Tilendor Jun 18 '09 at 19:19
  • 1
    I was having the same problem with a Python script running in Windows CMD, Ctrl+Pause did the trick – Sébastien Sep 20 '11 at 19:30
  • I don't have a Pause/Break key on my Dell Laptop. What shall I do? – Shobhit Jul 01 '12 at 07:38
  • nice one :D ctrl+c is once again broken in rails 3.2.1 tx for the save :D – Francois Jul 10 '12 at 13:39
  • +1 Using Rails 3.2.1 in Windows 7 64bit CTRL+C didn't work but CTRL+Pause/Break did. – Nope Feb 19 '13 at 13:05
10

Ctrl+Pause/Break force closes the server. It's not normal. Anyways my Dell notebook does not have the key.

So use this:
instead of rails s use ruby script/rails s.
Ctrl+C will work perfectly with that. Tested it.

Be Brave Be Like Ukraine
  • 7,596
  • 3
  • 42
  • 66
Akash
  • 5,153
  • 3
  • 26
  • 42
2

It's a known issue and here is the patch:https://rails.lighthouseapp.com/projects/8994/tickets/2088-mongrel-not-being-stopped-with-ctrl-c-under-windows

atambo
  • 81
  • 3
1

If all fails, hit Ctrl+Alt+Delete, open the task manager and just kill the ruby process ;) Ruby process

icodebuster
  • 8,890
  • 7
  • 62
  • 65
Gregra
  • 773
  • 8
  • 22
1

I believe this can happen if you are catching Exception and not re raising it. SIG-INT would be caught there and ultimately not kill the process.

Kyle Boon
  • 5,213
  • 6
  • 39
  • 50
  • how can i check if this is happening. i know i did not explicitly add an exception catch for SIG-INT or any other exception (yet) as I am just following a basic tutorial – Jayrox Apr 30 '09 at 17:39
  • Just search your project for "rescue Exception". – Bob Aman May 22 '09 at 17:12
0

After you hit Ctrl+c, send a request to the server by refreshing your browser page where you had it open. The command prompt will now say Exiting and let you back to the command line.

António Almeida
  • 9,620
  • 8
  • 59
  • 66
0

Check your rails version and use

ctrl+c+pause/break for 2.3.2
ctrl+c for 2.1.2

Hulk1991
  • 3,079
  • 13
  • 31
  • 46
hira
  • 1
0

I have the same problem on Windows as well, so can't help you in fixing the Ctrl+C issue. But, I can point you towards Windows PowerToys' Open Command Window Here - it adds "Open Command Window Here" to your Explorer window, it's a requirement for development (of any sort) on Windows machines.

Michael Wales
  • 10,360
  • 8
  • 28
  • 28
  • Well, thats definitely a start. I can't imagine we are the only two people on SO that have used Rails on windows and have a problem with CTRL+C killing the server. – Jayrox Apr 21 '09 at 00:54
  • I use windows (xp) and have no problem killing my server. – srboisvert Apr 21 '09 at 13:13
0

If you start mongrel a little different like this:

$ cd myrailsapp
$ mongrel_rails start

then you can stop it like this:

$ mongrel_rails stop

You can get more info here. This might be interesting to: Mongrel as a service

dertoni
  • 1,763
  • 2
  • 24
  • 47