diff --git a/shared/additional-modules/ruby/manifests/falcon.pp b/shared/additional-modules/ruby/manifests/falcon.pp new file mode 100644 index 0000000..7148291 --- /dev/null +++ b/shared/additional-modules/ruby/manifests/falcon.pp @@ -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" + } +} + diff --git a/shared/additional-modules/ruby/manifests/init.pp b/shared/additional-modules/ruby/manifests/init.pp index 88973d3..93b0097 100644 --- a/shared/additional-modules/ruby/manifests/init.pp +++ b/shared/additional-modules/ruby/manifests/init.pp @@ -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", configure => $configure, preconfigure => "LDFLAGS='-rdynamic -Wl,-export-dynamic'", - path => "${build_path}:${with_ruby_path}" + path => $build_path } if ($osfamily == 'debian') { diff --git a/shared/additional-modules/ruby/templates/falcon-patch.sh b/shared/additional-modules/ruby/templates/falcon-patch.sh new file mode 100644 index 0000000..5938d82 --- /dev/null +++ b/shared/additional-modules/ruby/templates/falcon-patch.sh @@ -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 + diff --git a/shared/lib/puppet/provider/configure/action.rb b/shared/lib/puppet/provider/configure/action.rb index ffd4cc8..e1e718d 100644 --- a/shared/lib/puppet/provider/configure/action.rb +++ b/shared/lib/puppet/provider/configure/action.rb @@ -2,8 +2,10 @@ Puppet::Type.type(:configure).provide(:action) do desc "Configure a program to install" 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 $? + puts command raise StandardError.new("Could not configure") if $?.exitstatus != 0 end @@ -31,7 +33,7 @@ Puppet::Type.type(:configure).provide(:action) do end def path - @resource[:path].empty? ? '' : "PATH=#{@resource[:path]}:$PATH " + @resource[:path].empty? ? '' : "PATH=#{@resource[:path]} " end end diff --git a/shared/lib/puppet/provider/god_init/install.rb b/shared/lib/puppet/provider/god_init/install.rb index a76902f..5d4ad29 100644 --- a/shared/lib/puppet/provider/god_init/install.rb +++ b/shared/lib/puppet/provider/god_init/install.rb @@ -1,7 +1,17 @@ require 'erb' 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 FileUtils.mkdir_p File.dirname(file) @@ -21,57 +31,28 @@ Puppet::Type.type(:god_init).provide(:install) do ERB.new(config).result(binding) end - private - 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_resources :start, :group, :name, :dir def interval - @resource[:interval] || 5 + @resource[:interval] || 30 + end + + private + def file + File.join(dir, "#{name}.god") end def config <<-GOD God.watch do |w| w.name = "<%= name %>" + <% if !group.empty? %> + w.group = "<%= group %>" + <% end %> + w.interval = <%= interval %>.seconds - w.start = lambda { system("<%= 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 = %{<%= start %>} w.start_if do |start| start.condition(:process_running) do |c| diff --git a/shared/lib/puppet/type/god_init.rb b/shared/lib/puppet/type/god_init.rb index c5a36dd..a0c829f 100644 --- a/shared/lib/puppet/type/god_init.rb +++ b/shared/lib/puppet/type/god_init.rb @@ -11,22 +11,14 @@ Puppet::Type.newtype(:god_init) do desc "The command to start the process" end - newparam(:stop) do - desc "The command to stop the process" - end - - newparam(:restart) do - desc "The command to restart/reload the process" + newparam(:group) do + desc "The group this process belongs to" end newparam(:dir) do desc "The directory where god configs are held" end - newparam(:pid_file) do - desc "A pid file" - end - newparam(:interval) do desc "The check interval" end