Teach foreman a little bit about god
This commit is contained in:
parent
bae849ae5d
commit
2e2ccb9f14
|
@ -0,0 +1,11 @@
|
|||
<% engine.procfile.entries.each do |process| %>
|
||||
<% 1.upto(concurrency[process.name]) do |num| %>
|
||||
God.watch do |w|
|
||||
w.name = "<%= "#{process.name}-#{num}" %>"
|
||||
w.start = "<%= process.command %>"
|
||||
w.keepalive
|
||||
w.group = "<%= process.name %>"
|
||||
<%= extension(process.name) %>
|
||||
end
|
||||
<% end %>
|
||||
<% end %>
|
|
@ -0,0 +1,5 @@
|
|||
# Unicorn specific
|
||||
w.pid_file = "<%= engine.directory + "/tmp/pids/unicorn.pid" %>"
|
||||
w.stop = "kill -QUIT `cat #{w.pid_file}`"
|
||||
w.restart = "kill -USR2 `cat #{w.pid_file}`"
|
||||
w.behavior(:clean_pid_file)
|
|
@ -1,10 +1,9 @@
|
|||
# -*- encoding: utf-8 -*-
|
||||
$:.push File.expand_path("../lib", __FILE__)
|
||||
require "foreman-export-god/version"
|
||||
|
||||
Gem::Specification.new do |s|
|
||||
s.name = "foreman-export-god"
|
||||
s.version = Foreman::Export::God::VERSION
|
||||
s.version = "0.0.1"
|
||||
s.authors = ["Bob Potter"]
|
||||
s.email = ["bobby.potter@gmail.com"]
|
||||
s.homepage = ""
|
||||
|
|
|
@ -1,9 +1,3 @@
|
|||
require "foreman-export-god/version"
|
||||
$:.unshift(File.dirname(__FILE__))
|
||||
|
||||
module Foreman
|
||||
module Export
|
||||
module God
|
||||
# Your code goes here...
|
||||
end
|
||||
end
|
||||
end
|
||||
require 'foreman/export/god'
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
module Foreman
|
||||
module Export
|
||||
module God
|
||||
VERSION = "0.0.1"
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,55 @@
|
|||
require 'foreman/export'
|
||||
require 'foreman/cli'
|
||||
|
||||
class Foreman::Export::God < Foreman::Export::Base
|
||||
def export
|
||||
error("Must specify a location") unless location
|
||||
FileUtils.mkdir_p location
|
||||
|
||||
app = self.app || File.basename(engine.directory)
|
||||
|
||||
base_config = ERB.new(base_template).result(binding)
|
||||
puts base_config
|
||||
|
||||
write_file(File.join(location, "#{app}.god"), base_config)
|
||||
end
|
||||
|
||||
def extension(process_name)
|
||||
p extensions
|
||||
if extensions.has_key?(process_name)
|
||||
ERB.new(extension_template(process_name)).result(binding)
|
||||
else
|
||||
""
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def template_path
|
||||
Pathname.new(File.dirname(__FILE__)).join('..', '..', '..', 'data', 'templates')
|
||||
end
|
||||
|
||||
def base_template
|
||||
IO.read(base_template_path)
|
||||
end
|
||||
|
||||
def base_template_path
|
||||
base_template = File.join(template_path, "base.god.erb")
|
||||
end
|
||||
|
||||
def extension_template(name)
|
||||
IO.read(extensions[name])
|
||||
end
|
||||
|
||||
def extensions
|
||||
@extensions = load_extensions
|
||||
end
|
||||
|
||||
def load_extensions
|
||||
h = {}
|
||||
Dir.glob(template_path.join('extensions') + "*.erb").each do |extension_path|
|
||||
extension_name = extension_path.split("/").last.match(/(.*?).god.erb$/)[1]
|
||||
h[extension_name] = extension_path
|
||||
end
|
||||
h
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue