change the way things work

This commit is contained in:
John Bintz 2012-07-10 16:03:16 -04:00
parent 0ac18b0e94
commit 9d66fe8943
6 changed files with 63 additions and 55 deletions

View File

@ -0,0 +1,23 @@
class ruby::falcon($version, $configure, $build_path) {
class { ruby:
version => $version,
configure => $configure,
build_path => $build_path
}
file { '/tmp/ruby-falcon-patch.sh':
content => template('ruby/falcon-patch.sh'),
before => Configure['ruby'],
mode => 755
}
exec { 'patch-ruby':
command => "ruby-falcon-patch.sh",
before => Configure['ruby'],
cwd => build_path('ruby', $version),
unless => 'test -f patched',
logoutput => true,
path => "/tmp:$base::path"
}
}

View File

@ -21,7 +21,7 @@ class ruby($version = '', $deb_url = '', $configure = "--disable-install-doc", $
source => "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-<%= version %>.tar.gz", source => "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-<%= version %>.tar.gz",
configure => $configure, configure => $configure,
preconfigure => "LDFLAGS='-rdynamic -Wl,-export-dynamic'", preconfigure => "LDFLAGS='-rdynamic -Wl,-export-dynamic'",
path => "${build_path}:${with_ruby_path}" path => $build_path
} }
if ($osfamily == 'debian') { if ($osfamily == 'debian') {

View File

@ -0,0 +1,10 @@
#!/bin/bash
curl https://raw.github.com/gist/2593385/perf_and_gc.diff | patch -p1
if [ $? -ne 0 ]; then exit 1; fi
curl https://raw.github.com/gist/2502451/46c9fbc07abf7ea5670ba0e23a11ff93d6e3c9db/yaml.rb.diff | patch -p1
if [ $? -ne 0 ]; then exit 1; fi
touch patched

View File

@ -2,8 +2,10 @@ Puppet::Type.type(:configure).provide(:action) do
desc "Configure a program to install" desc "Configure a program to install"
def create def create
system %{bash -c "cd #{@resource[:build_path]} && #{@resource[:preconfigure].gsub('"', '\\"')} #{path} ./configure --prefix=#{@resource[:install_path]} #{@resource[:options]}"}.tap { |o| p o } command = %{bash -c "env ; sleep 10 ; cd #{@resource[:build_path]} && #{@resource[:preconfigure].gsub('"', '\\"')} #{path} ./configure --prefix=#{@resource[:install_path]} #{@resource[:options]}"}.tap { |o| p o }
system command
p $? p $?
puts command
raise StandardError.new("Could not configure") if $?.exitstatus != 0 raise StandardError.new("Could not configure") if $?.exitstatus != 0
end end
@ -31,7 +33,7 @@ Puppet::Type.type(:configure).provide(:action) do
end end
def path def path
@resource[:path].empty? ? '' : "PATH=#{@resource[:path]}:$PATH " @resource[:path].empty? ? '' : "PATH=#{@resource[:path]} "
end end
end end

View File

@ -1,7 +1,17 @@
require 'erb' require 'erb'
Puppet::Type.type(:god_init).provide(:install) do Puppet::Type.type(:god_init).provide(:install) do
desc "Install a God script" desc "Install a God script for a non-daemonized process"
def self.def_resources(*args)
args.each do |arg|
class_eval <<-RB
def #{arg}
@resource[:#{arg}] || ''
end
RB
end
end
def create def create
FileUtils.mkdir_p File.dirname(file) FileUtils.mkdir_p File.dirname(file)
@ -21,57 +31,28 @@ Puppet::Type.type(:god_init).provide(:install) do
ERB.new(config).result(binding) ERB.new(config).result(binding)
end end
private def_resources :start, :group, :name, :dir
def file
File.join(@resource[:dir], "#{@resource[:name]}.god")
end
def start
@resource[:start] || ''
end
def stop
@resource[:stop] || ''
end
def restart
@resource[:restart] || ''
end
def name
@resource[:name] || ''
end
def pid_file
@resource[:pid_file] || ''
end
def interval def interval
@resource[:interval] || 5 @resource[:interval] || 30
end
private
def file
File.join(dir, "#{name}.god")
end end
def config def config
<<-GOD <<-GOD
God.watch do |w| God.watch do |w|
w.name = "<%= name %>" w.name = "<%= name %>"
<% if !group.empty? %>
w.group = "<%= group %>"
<% end %>
w.interval = <%= interval %>.seconds w.interval = <%= interval %>.seconds
w.start = lambda { system("<%= start %>") } w.start = %{<%= start %>}
w.start_grace = <%= interval %>.seconds
<% if !stop.empty? %>
w.stop = lambda { system("<%= stop %>") ; system("killall -9 <%= name %>") }
<% end %>
<% if !restart.empty? %>
w.restart = lambda { system("<%= restart %>") }
<% end %>
<% if pid_file %>
w.pid_file = "<%= pid_file %>";
<% else %>
w.behavior(:clean_pid_file)
<% end %>
w.start_if do |start| w.start_if do |start|
start.condition(:process_running) do |c| start.condition(:process_running) do |c|

View File

@ -11,22 +11,14 @@ Puppet::Type.newtype(:god_init) do
desc "The command to start the process" desc "The command to start the process"
end end
newparam(:stop) do newparam(:group) do
desc "The command to stop the process" desc "The group this process belongs to"
end
newparam(:restart) do
desc "The command to restart/reload the process"
end end
newparam(:dir) do newparam(:dir) do
desc "The directory where god configs are held" desc "The directory where god configs are held"
end end
newparam(:pid_file) do
desc "A pid file"
end
newparam(:interval) do newparam(:interval) do
desc "The check interval" desc "The check interval"
end end