Why does my WEBrick server get killed?
Asked Answered
O

1

9

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?

Ohara answered 5/1, 2014 at 9:22 Comment(9)
Are you sure you want to use webrick only? why not try Thin?Grannia
This might be a restriction of digital-ocean. Or your internet connection is not stable.Ingrained
Also, I'm running this in tmux, so the process is running whether I'm connected to the machine, or not. (thanks @Ingrained for pointing that out).Ohara
@Grannia I'm open to using thin. But, I want to understand why this is happening first.Ohara
So you run rails c over ssh on remote server? I bet on ssh session being terminated/timed out so all processes in session are also killed.Aretha
@MichaelSzyndel: I can run rails c on the remote server. Also, I'm running it in tmux so that I can attach and detach from the server w/o killing processes.Ohara
I still think you should contact your provider support or do it the proper way (with i.e. ngnix, etc)Aretha
@MichaelSzyndel why is running a development server on WEBrick not the proper way?Ohara
Webrick is meant for use on developer machine not on a server. It really won't hurt you to do it well.Aretha
G
15

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 :)

Gasoline answered 9/1, 2014 at 5:9 Comment(1)
This seems like a very reasonable answer. I just implemented a swap file, and did a little load test with ab to see if I could get it to crash, and it stayed up.Ohara

© 2022 - 2024 — McMap. All rights reserved.