how can I stop my server from freezing when powershell is in 'select' mode? - ruby-on-rails

I didn't believe this until I tested it a few times, but it's really happening.
Start rails server and app from powershell: 'rails s'
open a web page from that server
note how long the page took to get served up
now in powershell, select some text
reload the webpage from step 2
note that the webpage is taking forever to load
set up the windows so that you can see the powershell window and web page at the same time
go back to powershell and hit 'Enter' (so that the selected text is copied)
note that the web page loads as soon as the powershell window leaves select mode
TLDR: Rails server started via powershell won't serve pages while powershell is in 'Select' mode.
Is there some setting in powershell that will stop it from doing this? I can see it being helpful when selecting text in the middle of a bat run but when it stops my server it's flipping obnoxious.

Open a powershell window that you would normally start rails in. Open the properties dialog for the window and deselect QuickEdit Mode on the Options tab.

I had commented thinking it was just a general issue with the console system, and it probably still is as I cannot see how powershell is involved here as it's just a parent process, but it appears to be isolated to code that is watching for input. I think the rails server might be looking for input during its main loop, and perhaps selecting text in the console is blocking this. Take this simple script that loops - but does not watch for input - on a single thread, writing to a debug listener:
ps> $i = 0
ps> while (1) { sleep -seconds 1; [diagnostics.trace]::writeline("ping: $i"); $i++ }
Now, run sysinternals/microsoft's free DbgView tool to watch the output. I am using a separate tool instead of writing to the console because this is more like your scenario where web pages are being served in the background to a socket. You can get DbgView from:
http://technet.microsoft.com/en-us/sysinternals/bb896647
When I select the text in the console, the script does not pause. I even stuffed in a check in the key buffer, and it still did not stop.
I think the Rails server is doing some kind of key checking which is being blocked somehow and interfering with its ability to process requests. It seems retarded, but my script doesn't fail even if I stuff in a check for [console]::keyavailable
ps> while (1) {
>> sleep -seconds 1;
>> [diagnostics.trace]::writeline("ping: $i");
>> $i++
>> $dummy = [console]::keyavailable
>> }
Looks like it's Rail's fault, albeit unintentionally of course.

Related

Terminal cursor disappears when using Rails server and pry/byebug together

If I trigger pry or byebug, eventually while using the live-debug mode the cursor will disappear, and input will become slow/laggy. Ultimately I have to Ctrl-C and kill the unicorn/puma process. After I've quit the process the terminal works, but the cursor is sometimes still missing/invisible. Then I have to close the terminal and open another. I've tried two different servers (puma/unicorn) and two different debugging tools (pry and byebug).
Hard to say if this is related to the debug tool, the rails server or my Terminal. I'm using Terminal.app with Solarized theme.
When the cursor disappears you can enter the command stty echo and hit enter. That should bring the cursor back.

Running Cloud9 program for BeagleBone Black does nothing, then eventually stops at first line

I am using a BBB with the Debian distro. I access Cloud9 (192.168.7.2:3000) via Chrome on my Windows 7 machine. I am able to access existing demo js programs and have written a test program (myblink.js). The editor and overall system works fine.
But when I try to run the program, nothing happens for a few seconds, then eventually, it appears to stop on the first line (which becomes highlighted yellow). When this happens, the debugger panel pops out and the bottom window shows that the "debugger listening on port 15454" and I have the option to stop the program. At this point I can step through the program, well, at least to the point where there is some asynchronous events handling required.
However, if I run "node myblink.js" app from the bash tab in Cloud9 or from a shell (via putty) it works perfectly fine.
Do I have to set anything up to enable debugging? Or is it too much to expect from the debugger and a BBB system?

How can I stop executing .wlua files?

Is it possible to force stop a .wlua file? I figured that I would have to use the Lua Command Line to do this, but I can't seem to find out how to stop them.
If it's possible, how can it be done?
Because wlua.exe doesn't open the console window (that's the purpose) and you can't send Ctrl-C, the only way to terminate such application is to use Processes window in Task Manager. Note, however, that the process name will be wlua.exe for every file opened that way.
Of course, it's meant only to be used when the application isn't responding. Your GUI application should provide a way to close it, such as close button, listening for ESC key etc.

Command Prompt input

I have a Windows 7 laptop, and I think I installed everything correctly, and I am trying to follow a couple tutorials to learn from. I can make a new application ok, and I can start the server just fine by typing "rails server", and I can go to the localhost:3000 'welcome aboard' page just fine, but after that the tutorials ask me to type other stuff into the command prompt window. The problem is, with the server running, I can't type anything into the command prompt window! I'm obviously doing something wrong.. anyone have any idea of what I should be doing?
The easiest way is to open another command window.
I set up students to use more than one command window like this:
one for typing most commands
one for running the server
one for printing the log file using the "tail -f" command to show ongoing progress
one for running rails console

Unpause a rails server that was paused in a different terminal window

I'm on mac osx using zsh. If I start a rails server with "rails s" I can put it in the background by hitting "ctrl-z" in my terminal (zsh).
If I open up a different terminal window then I don't see the rails server if I do "jobs". However, I can see it when I do "ps".
Is there a way I can somehow "unpause" the rails server in this new 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.
The job is "stopped" by sending it a SIGSTOP.Your C-z doesn't send the job into the background. It "stops" it. You can then move it into the background using the bg shell builtin. However, if you send this process a SIGCONT (kill -CONT <pid>), it should bring the process back to the foreground. This can be done from a different shell.
You will not see it if you type jobs because it is a job controlled by a different shell (the other terminal window and not the one where you typed jobs). Processes however are "global" and can be seen from anywhere using the ps command (as you rightly pointed out).
Update: Looks like I spoke too soon. Apparently, the signal alone isn't enough to bring it back to the foreground. Probably something to do with the shell.

Resources