From 6f255496688666843905d3ce01b9736341a624e1 Mon Sep 17 00:00:00 2001
From: Michael Brown <michael.brown@discourse.org>
Date: Mon, 30 Sep 2013 15:16:52 -0400
Subject: [PATCH] Add process checks to kill/restart too large thins

---
 config/discourse.pill.sample | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/config/discourse.pill.sample b/config/discourse.pill.sample
index 24455d896..830455bba 100644
--- a/config/discourse.pill.sample
+++ b/config/discourse.pill.sample
@@ -72,6 +72,9 @@ Bluepill.application("discourse", :base_dir => ENV["HOME"] + '/.bluepill') do |a
       process.gid = group
       process.daemonize = false
       process.stdout = process.stderr = "#{rails_root}/log/thin#{i}.log"
+      # Thanks to: http://www.garrensmith.com/2012/09/24/Staying-up-with-Unicorn-Upstart-Bluepill.html
+      # If the amount of memory is exceeded 3 times out of 5, restart
+      process.checks :mem_usage, :every => 1.minutes, :below => 750.megabytes, :times => [3, 5]
     end
   end