Permalink
Browse files

integrate pylon/dcell w/ chef-solo

  • Loading branch information...
fujin committed Feb 5, 2012
1 parent c664645 commit 611606ff2ded2b5ddb0371c18a7f78552c916732
Showing with 158 additions and 38 deletions.
  1. +4 −4 .rvmrc
  2. +3 −1 .travis.yml
  3. +8 −13 Vagrantfile
  4. +30 −0 bin/chef-solo-pylon
  5. +16 −17 cookbooks/pylon/recipes/default.rb
  6. +1 −1 lib/pylon.rb
  7. +15 −0 lib/pylon/application.rb
  8. +78 −0 lib/pylon/application/solo_pylon.rb
  9. +3 −2 pylon.gemspec
View
8 .rvmrc
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
-ruby_string="jruby-1.6.6"
+ruby_string="ruby-1.9.3-p0"
gemset_name="pylon-dcell"
if rvm list strings | grep -q "${ruby_string}" ; then
@@ -10,7 +10,8 @@ if rvm list strings | grep -q "${ruby_string}" ; then
&& -s "${rvm_path:-$HOME/.rvm}/environments/${ruby_string}@${gemset_name}" ]] ; then
\. "${rvm_path:-$HOME/.rvm}/environments/${ruby_string}@${gemset_name}"
else
- rvm --create "${ruby_string}@${gemset_name}"
+ rvm gemset create ${gemset_name}
+ rvm gemset use ${gemset_name}
fi
(
@@ -19,8 +20,7 @@ if rvm list strings | grep -q "${ruby_string}" ; then
gem install bundler
fi
- # Bundle while redcing excess noise.
- bundle | grep -v 'Using' | grep -v 'complete' | sed '/^$/d'
+ bundle
)
else
View
@@ -3,4 +3,6 @@ language: ruby
script: bundle exec rake
rvm:
- - jruby-19mode
+ - 1.9.3
+ - 1.9.2
+ - ruby-head
View
@@ -1,18 +1,13 @@
-def pylon_vm(config=nil, name=:pylon, count=0)
- return unless config
- config.vm.define(name) do |config|
- config.vm.box = 'natty64_cloudscaling_4.1'
- config.vm.box_url = "http://d1lfnqkkmlbdsd.cloudfront.net/vagrant/natty64_cloudscaling_4.1.box"
- config.vm.network "33.33.33.#{10 + count}"
- config.vm.provision :chef_solo do |chef|
+Vagrant::Config.run do |config|
+ config.vm.define :cookbooks do |cookbooks|
+ cookbooks.vm.customize do |vm|
+ vm.memory_size = 4096
+ end
+ cookbooks.vm.box = "natty64"
+ cookbooks.vm.box_url = "https://s3.amazonaws.com/hw-vagrant/natty64.box"
+ cookbooks.vm.provision :chef_solo do |chef|
chef.cookbooks_path = "cookbooks"
chef.add_recipe "pylon"
end
end
end
-
-Vagrant::Config.run do |config|
- 10.times do |i|
- pylon_vm(config, "pylon#{i}".to_sym, i)
- end
-end
View
@@ -0,0 +1,30 @@
+#!/usr/bin/env ruby
+#
+# ./chef-solo-pylon
+#
+# Author:: AJ Christensen (<aj@junglist.gen.nz>)
+# Copyright:: Copyright (c) 2012 AJ Christensen
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or#implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+require "rubygems" unless RUBY_PLATFORM =~ /1.9/
+
+lib = File.expand_path('../../lib', __FILE__)
+$:.unshift(lib) unless $:.include?(lib)
+
+require_relative "../lib/pylon"
+require_relative "../lib/pylon/application"
+require_relative "../lib/pylon/application/solo_pylon"
+
+Pylon::Application::SoloPylon.new.run
@@ -17,27 +17,26 @@
# limitations under the License.
#
-execute "apt-get update"
-%w{zeromq build-essential tmux}.each do |pkg|
- package pkg
-end
+# we shouldn't need to require dcell, celluloid, or anything. should
+# already be loaded.
-execute "rsync -avu --progress --delete /vagrant/ /srv/pylon/" do
- notifies :delete, "directory[/srv/pylon/vendor/bundle]"
- notifies :run, "execute[bundle]"
-end
+class Test
+ include Celluloid
-directory "/srv/pylon/vendor/bundle" do
- action :nothing
- recursive true
+ def test
+ true
+ end
end
-execute "bundle" do
- command "bundle install --deployment"
- cwd "/srv/pylon"
- user "vagrant"
- group "vagrant"
- action :nothing
+class TestGroup < Celluloid::Group
+ supervise Test, :as => :test_class
end
+log "testing pylon"
+
+ruby_block "supervise test class" do
+ block do
+ TestGroup.run!
+ end
+end
View
@@ -16,7 +16,7 @@
class Pylon
PYLON_ROOT = File.dirname(File.expand_path(File.dirname(__FILE__)))
- VERSION = "0.2.8"
+ VERSION = "0.2.9"
end
unless Kernel.respond_to?(:require_relative)
View
@@ -25,11 +25,26 @@
class Pylon
class Application
class << self
+ def debug_stacktrace e
+ message = "#{e.class}: #{e}\n#{e.backtrace.join("\n")}"
+ chef_stacktrace_out = "Generated at #{Time.now.to_s}\n"
+ chef_stacktrace_out += message
+
+ Chef::FileCache.store("chef-stacktrace.out", chef_stacktrace_out)
+ Chef::Log.fatal("Stacktrace dumped to #{Chef::FileCache.load("chef-stacktrace.out", false)}")
+ Chef::Log.debug(message)
+ true
+ end
+
def fatal! message, error_code = -1
Pylon::Log.fatal message
Process.exit error_code
end
+ def exit! message, error_code = -1
+ Pylon::Log.debug message
+ Process.exit error_code
+ end
end
include Mixlib::CLI
@@ -0,0 +1,78 @@
+#
+# Author:: AJ Christensen (<aj@opscode.com>)
+# Author:: Mark Mzyk (mmzyk@opscode.com)
+# Copyright:: Copyright (c) 2008 Opscode, Inc.
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+require "pylon/dcell"
+require "pylon/application"
+
+# Chef libs to launch chef-solo
+require "chef"
+require "chef/application/solo"
+require "chef/config"
+
+class Pylon::Application::SoloPylon < Chef::Application::Solo
+
+ option :dcell_id,
+ :long => "--dcell-id DCELL_ID",
+ :description => "The ID to use for dcell communication",
+ :required => true
+
+ option :dcell_addr,
+ :short => "-a DCELL_ADDR",
+ :long => "--dcell-addr DCELL_ADDR",
+ :description => "The tcp zeromq endpoint to use for dcell communication, e.g. tcp://0.0.0.0:1234",
+ :default => "tcp://0.0.0.0:1234"
+
+ option :dcell_registry_adapter,
+ :long => "--dcell-registry-adapter DCELL_REGISTRY_ADAPTER",
+ :description => "Which adapter DCell should use for its registry, either zk or redis -- zk only available on JRuby",
+ :default => "redis",
+ :required => true
+
+ option :dcell_registry_server,
+ :long => "--dcell-registry-server DCELL_REGISTRY_server",
+ :description => "The host where the DCell registry is running",
+ :default => "localhost",
+ :required => true
+
+ option :dcell_registry_PORT,
+ :long => "--dcell-registry-port DCELL_REGISTRY_PORT",
+ :description => "The port where the DCell registry is running",
+ :default => 6379,
+ :required => true
+
+ option :dcell_registry_password,
+ :long => "--dcell-registry-password DCELL_REGISTRY_PASSWORD",
+ :description => "The password for the dcell registry, only used for Redis",
+ :required => false
+
+ def initialize
+ self.class.options.merge!(Chef::Application::Solo.options)
+ super
+ end
+
+ def setup_application
+ Pylon::Config.merge!(config)
+ Pylon::Log.logger = Chef::Log.logger
+ super
+ end
+
+ def run_application
+ Pylon::DCell.new
+ super
+ end
+end
View
@@ -10,10 +10,10 @@ Gem::Specification.new do |s|
s.default_executable = %q{pylon}
s.description = %q{leader election with zeromq for ruby using widely available leader election algorithms, similar to gen_leader erlang project in essence}
s.email = %q{aj@junglist.gen.nz}
- s.executables = ["pylon"]
+ s.executables = %w{pylon chef-solo-pylon}
s.extra_rdoc_files = [
"LICENSE",
- "README.org"
+ "readme.md"
]
s.files = Dir["lib/**/*.rb"] + Dir["bin/*"] + Dir["cookbooks/**/*"]
s.homepage = %q{http://github.com/fujin/pylon}
@@ -29,6 +29,7 @@ Gem::Specification.new do |s|
{ "bundler" => "~> 1.0.0",
"jeweler" => "~> 1.6.4",
"purdytest" => "~> 1.0.0",
+ "vagrant" => "~> 0.8"
}.each do |gem, version|
s.add_development_dependency(gem, [version])
end

0 comments on commit 611606f

Please sign in to comment.