diff --git a/data/templates/base.god.erb b/data/templates/base.god.erb index fe67f83..fcecd50 100644 --- a/data/templates/base.god.erb +++ b/data/templates/base.god.erb @@ -1,12 +1,21 @@ <% engine.procfile.entries.each do |process| %> <% 1.upto(concurrency[process.name]) do |num| %> + <% p process.name %> God.watch do |w| w.name = "<%= "#{process.name}-#{num}" %>" w.start = "<%= process.command %>" + w.env = { 'RAILS_ENV' => <%= ENV['RAILS_ENV'] %> } w.keepalive w.group = "<%= app %>" w.dir = "<%= engine.directory %>" <%= extension(process.name) %> + + w.restart_if do |restart| + restart.condition(:memory_usage) do |c| + c.above = 500.megabytes + c.times = [5, 10] # 3 out of 5 intervals + end + end end <% end %> <% end %> diff --git a/data/templates/extensions/delayed_job.god.erb b/data/templates/extensions/delayed_job.god.erb new file mode 100644 index 0000000..3d80079 --- /dev/null +++ b/data/templates/extensions/delayed_job.god.erb @@ -0,0 +1,19 @@ + # delayed_job specific + w.start_if do |start| + start.condition(:process_running) do |c| + c.interval = 5.seconds + c.running = false + end + end + + w.restart_if do |restart| + restart.condition(:memory_usage) do |c| + c.above = 300.megabytes + c.times = [3, 5] # 3 out of 5 intervals + end + + restart.condition(:cpu_usage) do |c| + c.above = 50.percent + c.times = 5 + end + end