Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

integrate pylon/dcell w/ chef-solo

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

0 notes on commit 611606f

Please sign in to comment.
Something went wrong with that request. Please try again.