Why does my WEBrick server get killed? - ruby-on-rails

I've got a rails development environment running in DigitalOcean on Ubuntu 12.04, but my WEBrick process keeps getting "killed" after a couple of hours. I haven't been able to find any settings or configuration that would cause this.
Example Console Ouput:
user#machinename:~/git/app$ rails s
=> Booting WEBrick
=> Rails 3.2.13 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2014-01-05 09:14:29] INFO WEBrick 1.3.1
[2014-01-05 09:14:29] INFO ruby 2.0.0 (2013-11-22) [x86_64-linux]
[2014-01-05 09:14:29] INFO WEBrick::HTTPServer#start: pid=23452 port=3000
Started GET "/" for x.x.x.x at 2014-01-05 09:14:37 +0000
Processing by FunController#welcome as HTML
...
The server and app run just fine when I'm using it. But, at some point, my server will quit working. And, I'll look at the console to see this output from WEBrick:
Killed
And kick me back out to the shell. Any ideas what is causing this?

It runs out of memory. The linux kernel kills it. Droplets don't come with any 'swap' by default, so when the memory gets full, it kills a process or won't let you start a new one. Kinda crazy.
Here's an article walking you through adding a swapfile:
https://www.digitalocean.com/community/articles/how-to-add-swap-on-ubuntu-12-04
Note: I still had some problems with compiler processes being 'killed' even after adding a swapfile when 'swappiness' was set to 0. Upping it to 20 fixed the problem.
Note2: You really shouldn't use webrick in production as others have mentioned in the comments. Still, a question is a question :)

Related

"Rails s" has abruptly stopped working

I was getting a bit frustrated with a project I have been working on for the past few days, so I decided to make a little blog for fun (and practice). I created the new rails application and tried to boot it up with “rails s”, but it didn’t work. Confused, I went back to my last project, started the server there, went to localhost:3000 like I have been for the past 2 months, but then ran into the same issue. It had been working 5 minutes earlier, but now neither it, nor any other projects will start.
Here is what I see in the command prompt:

C:\Users\mathi_000\Desktop\fPen\rails s
DL is deprecated, please use Fiddle
=> Booting WEBrick 
=> Rails 4.1.8 application starting in development on http://0.0.0.0:3000
=> Run ‘rails server –h’ for more startup options
=> Notice: server is listening on all interfaces (0.0.0.0). Consider
using 127.0.0.1 (--binding option)
When I go to localhost:3000, I am met with the "This page can't be displayed" message. Hopefully one of you can tell me what I screwed up! I am still in the process of learning, but this is obviously a rather large hindrance.
There's not much to go on here, but give my standard solution to these sorts of problems a go: spring stop then try again.

Aptana Studio: A server is already running error

Sometimes when I boot up my computer then open up Aptana Studio for Rails, then try to start my server, I get the following error...
=> Booting WEBrick
=> Rails 3.2.11 application starting in development on http://localhost:3000
=> Call with -d to detach
A server is already running. Check C:/Users/bob/bob_rails_demo/Course_Stats/tmp/pids/server.pid.
=> Ctrl-C to shutdown server
Exiting
When I check that file metioned, I open the file and all it says inside the file is ...
512
Is there a fix for this? I don't see anything else running in task manager. BTW I am running rails 3.2.11 w/ Windows 7.
I have the same problem too, and it didn't happen before, so i believe it is some kind of bug. What I do to solve it is simply delete the server.pid at C:[pathToApp]\tmp\server.pid file before starting my server.
It is saying that PID (process id) 512 is running the server.
Go to Start -> then type taskmgr.exe. Then, go to the processes tab and look for that process and kill it. It might be a bug that it does not close the server correctly on exit.

Not getting debug output for view errors in development mode

This is very odd. At the moment, I have some kind of error in a view, but can't see what it is. Also, no debug output in the web server trace.
The Rails 3.2.2 app is an upgrade from 2.7.10, and I'm using "thin" as my development server. I do get normal debug output when the error occurs in other places.
EDIT: I'm running development, as you can see here:
=> Booting Thin
=> Rails 3.2.2 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
>> Thin web server (v1.3.1 codename Triple Espresso)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:3000, CTRL+C to stop
EDIT: I can duplicate this behavior by raising an exception in the controller.
Please check you development.rb and ensure that
config.consider_all_requests_local = true
Otherwise exceptions and stack traces will not be shown.
I would compare the files in your ./config directory of your app with those of a clean Rails 3.2 install. They've restructured things pretty significantly and there are often strange errors like this that popup if you don't properly upgrade all the config files.

started rails server, now what?

I'm new to ruby on rails and trying to start learning. I'm developing on mac os x. I updated rubygems and rails.
I've started the server and have gotten the rails welcome page but my terminal is hung up. If i quit the terminal the server ends. Here is the text in my terminal right now. the cursor is on a new row directly under the last line so anything i type doesn't do anything if entered(except go to new line).
Is there a command i'm missing to start creating controllers and views in the terminal?
Last login: Thu Dec 15 18:11:43 on ttys000
You have mail.
Joe-Blows-MacBook-Pro:~ joeblow$ cd desktop/code/blogg
Joe-Blows-MacBook-Pro:blogg joeblow$ rails server
=> Booting WEBrick
=> Rails 3.1.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-12-15 18:26:35] INFO WEBrick 1.3.1
[2011-12-15 18:26:35] INFO ruby 1.8.7 (2010-01-10) [universal-darwin10.0]
[2011-12-15 18:26:35] INFO WEBrick::HTTPServer#start: pid=25823 port=3000
Started GET "/assets/rails.png" for 127.0.0.1 at Thu Dec 15 18:26:39 -0600 2011
Served asset /rails.png - 304 Not Modified (1ms)
When developing Rails applications, you'll typically have several terminals open at once.
This terminal is just for watching the standard output logging from the server. You'll probably want another terminal open with tail -F /path/to/logs/logs to see all the logs at once, and another terminal open for your editing, rails generate ..., git, etc. uses. You might have one more open for script/console to give you an irb-alike interface "inside" your application.
Open your browser and go to http://127.0.0.1:3000
If you want to be able to use the console run
rails server &

Server failure: BUG gc_sweep(): unknown data type 0x0

My server keeps crashing. It is especially bad in localized parts of my app where the rest is fine. On one major page it is now happening every time. I've spent over an hour cutting out parts of code, restarting the server and seeing where it fails (i.e. whenever any segment of content is inserted), but my code doesn't seem to be reasonably likely to be causing these crashes.
The error message reads something like this:
c:\rubyjobs>ruby script/server
=> Booting Mongrel
=> Rails 2.3.5 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
C:/Rubystack/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/
active_record/autosave_association.rb:183: [BUG] gc_sweep(): unknown data type 0
x0(0x59d9030)
ruby 1.8.7 (2010-01-10 patchlevel 249) [i386-mingw32]
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
I'm not experienced with Rails and I have a feeling this issue is advanced and/or embedded. What's going on here?
This is a critical issue for the app so any help would be greatly appreciated.
Unfortunately, sometimes Ruby and Rails are not the most stable products out there. I remember 249 and/or 248 having lot's of problems crashing on MacOSX but working fine on Linux. I'm not sure what's the state on Windows, but if I were you I'd upgrade to the latest Ruby (1.8.7-p302 I believe) and the latests Rails (2.3.9).

Resources