cluster 0.6.5 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,6 @@
1
+ cluster-*.gem
2
+ pkg/
3
+ Session.vim
4
+ .DS_Store
5
+ .*.sw?
6
+ ._.DS_Store
data/Rakefile CHANGED
@@ -4,66 +4,6 @@ require File.join(File.dirname(__FILE__), 'lib', PKG_NAME, 'version')
4
4
  namespace :cluster do
5
5
  desc "Display #{Cluster::NAME} current version."
6
6
  task :version do
7
- puts "#{Cluster::NAME} is at version #{Cluster::Version::CURRENT}"
8
- end
9
-
10
- desc "Update the #{Cluster::NAME}.gem file at S3."
11
- task :update => :package do
12
- # Using right_aws directly to get around having to
13
- # have a fantastic require structure to use the
14
- # cluster tool itself to do this.
15
- #
16
- # Most particularly this means that error messages will
17
- # show up...
18
- require 'right_aws'
19
-
20
- Rightscale::HttpConnection.params = Rightscale::HttpConnection.params.merge(:ca_file => File.expand_path(File.join(File.dirname(__FILE__), 'lib', 'cluster', 'infrastructures', 'aws-certificates.crt')))
21
-
22
- oven = RightAws::S3.new(ENV['AMAZON_ACCESS_KEY_ID'], ENV['AMAZON_SECRET_ACCESS_KEY']).bucket(Cluster::BUCKET)
23
-
24
- unless oven
25
- STDERR.puts "Bucket by the name of #{Cluster::BUCKET} cannot be found or accessed."
26
- exit 1
27
- end
28
-
29
- filename = File.join('pkg', "#{Cluster::NAME}-#{Cluster::Version::STRING}.gem")
30
- file = open(filename)
31
- oven.put("#{Cluster::NAME}.gem", file, {}, 'public-read')
32
- end
33
- end
34
-
35
- # FIXME these RightAws calls could be refactored into one.
36
- # Not only that but they should probably be using the cluster
37
- # infrastructure...
38
- namespace :images do
39
- desc "List the current images used"
40
- task :show do
41
- require 'right_aws'
42
-
43
- oven = RightAws::S3.new(ENV['AMAZON_ACCESS_KEY_ID'], ENV['AMAZON_SECRET_ACCESS_KEY']).bucket(Cluster::BUCKET)
44
-
45
- unless oven
46
- STDERR.puts "Bucket by the name of #{Cluster::BUCKET} cannot be found or accessed."
47
- exit 1
48
- end
49
-
50
- filename = 'cluster_images.yml'
51
- puts oven.get(filename)
52
- end
53
-
54
- desc "Update the ec2 base image data"
55
- task :update do
56
- require 'right_aws'
57
-
58
- oven = RightAws::S3.new(ENV['AMAZON_ACCESS_KEY_ID'], ENV['AMAZON_SECRET_ACCESS_KEY']).bucket(Cluster::BUCKET)
59
-
60
- unless oven
61
- STDERR.puts "Bucket by the name of #{Cluster::BUCKET} cannot be found or accessed."
62
- exit 1
63
- end
64
-
65
- filename = 'cluster_images.yml'
66
- file = open(filename)
67
- oven.put(filename, file, {}, 'public-read')
7
+ puts "#{Cluster::NAME} is at version #{Cluster.version}"
68
8
  end
69
9
  end
@@ -0,0 +1,25 @@
1
+ PKG_NAME = ENV['PKG_NAME'] || 'cluster'
2
+ require File.join(File.dirname(__FILE__), 'lib', PKG_NAME, 'version')
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.version = Cluster.version.to_s
6
+ gem.name = Cluster::NAME
7
+ gem.executables = [Cluster::NAME]
8
+ gem.summary = %Q{Cluster control - manage many machines in many roles}
9
+ gem.description = %Q{You need to scale, you need control, you need feedback, you need monitoring. You get clustered!}
10
+ gem.email = [ Cluster::EMAIL ]
11
+ gem.authors = [ Cluster::AUTHOR ]
12
+ gem.has_rdoc = false
13
+
14
+ gem.files = `git ls-files`.split("\n")
15
+ gem.require_paths = ['lib']
16
+
17
+ gem.add_dependency "uuidtools", ">=2.1.1"
18
+ gem.add_dependency "right_aws"
19
+ # gem.add_dependency "ingamer_raws", ">= 2.1.0"
20
+ # gem.add_dependency "rake", ">=0.8.7"
21
+ # gem.add_dependency "god", ">=0.10.1"
22
+ # gem.add_dependency "capistrano", ">=2.5.18"
23
+ # gem.add_dependency "capistrano-ext", ">=1.2.1"
24
+ # gem.add_dependency "railsless-deploy", ">=1.0.0"
25
+ end
@@ -0,0 +1,2 @@
1
+ sixtyfour: 'ami-82c913eb'
2
+ name64: '854365875941/base_x86_64_54'
@@ -0,0 +1,2 @@
1
+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BgQAmSCwWwlj66BZ0DKqqX1Q/8tfJeGBeXm43YyJ3Nn6yF8Q0ufUI
17
+ hfzJATj/Tb7yFkJD57taRvvBxhEf8UqwKEbJw8RCfbz6q1lu1bdRiBHjpIUZa4JM
18
+ pAwSremkrj/xw0llmozFyD4lt5SZu5IycQfwhl7tUCemDaYj+bvLpgcUQg==
19
+ -----END CERTIFICATE-----
@@ -0,0 +1,24 @@
1
+ amazon:
2
+ user: 91*********
3
+ key: AKI**********
4
+ secret: U***************************
5
+
6
+ monitor:
7
+ email:
8
+ address: smtp.gmail.com
9
+ port: 587
10
+ domain: ingamersports.com
11
+ authentication: plain
12
+ user_name: dog@score345.com
13
+ password: *******
14
+ messages:
15
+ from: dog@ingamersports.com
16
+ contacts:
17
+ - name: alerts
18
+ email: alert@ingamersports.com
19
+ - name: panic
20
+ email: panic@ingamersports.com
21
+ group: emergency
22
+ - name: simon
23
+ email: sdeboer@ingamersports.com
24
+ group: person
@@ -0,0 +1,88 @@
1
+ #!/bin/env god -c
2
+ require 'rubygems'
3
+ require 'tlsmail'
4
+ require 'fileutils'
5
+ require 'cluster'
6
+ require 'cluster/infrastructures/amazon'
7
+
8
+ Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
9
+
10
+ CREDENTIALS = ENV['CREDENTIALS'] || File.join(ENV['HOME'], '.cluster', 'credentials.yml')
11
+
12
+ credentials_file = File.expand_path(CREDENTIALS)
13
+
14
+ unless File.exists?(credentials_file)
15
+ $stderr.puts "Cannot find credentials for cluster : #{credentials_file} !"
16
+ exit 2
17
+ end
18
+ MONITOR_PATH = File.join File.dirname(credentials_file), 'services.d'
19
+
20
+ Cluster::Configuration[:credentials_file] = credentials_file
21
+ CLUSTER = Cluster.new(Amazon.new)
22
+
23
+ class UserService < God::Behavior
24
+ def before_start
25
+ service = self.watch.name[/^(\w+)-/, 1]
26
+ users_file = File.join(MONITOR_PATH, service, 'users.sh')
27
+ unless File.exists? users_file
28
+ FileUtils.mkdir_p File.dirname users_file
29
+ CLUSTER.retrieve service, 'users.sh', users_file
30
+ end
31
+
32
+ system(users_file) if File.exists? users_file
33
+ end
34
+ end
35
+
36
+ class ProjectService < God::Behavior
37
+ def before_start
38
+ service = self.watch.name[/^(\w+)-/, 1]
39
+ end
40
+ end
41
+
42
+ creds = YAML::load_file credentials_file
43
+
44
+ if creds.include? 'monitor'
45
+ moni = creds['monitor']
46
+ email = moni['email'].keys.inject({}) {|m, k|
47
+ m.merge k.to_sym => moni['email'][k]
48
+ }
49
+ God::Contacts::Email.server_settings = email
50
+ God::Contacts::Email.message_settings = {
51
+ :from => moni['messages']['from']
52
+ }
53
+
54
+ if moni.include? 'contacts'
55
+ for contact in moni['contacts']
56
+ God.contact(:email) {|c|
57
+ c.name = contact['name']
58
+ c.email = contact['email']
59
+ contact['group'] and (c.group = contact['group'])
60
+ }
61
+ end
62
+ else
63
+ God.contact(:email) {|c|
64
+ c.name = 'system notification'
65
+ c.email = moni['messages']['from']
66
+ }
67
+ end
68
+ end
69
+
70
+ CLUSTER.instance_state('configuring')
71
+
72
+ for service in CLUSTER.current('services')
73
+ monitor_file = File.join MONITOR_PATH, service, "config.god"
74
+ FileUtils.mkdir_p File.dirname(monitor_file)
75
+ begin
76
+ CLUSTER.retrieve service, 'config.god', monitor_file
77
+ rescue => err
78
+ applog(nil, :warn, "Service of #{service} does not appear to have a monitor configuration. Skipping!")
79
+ next
80
+ end
81
+
82
+ if File.readable? monitor_file
83
+ applog(nil, :info, "Loading monitor file #{monitor_file}")
84
+ load monitor_file
85
+ else
86
+ applog(nil, :warn, "Cannot find a monitor file for #{monitor_file}")
87
+ end
88
+ end
@@ -0,0 +1,64 @@
1
+ class MemcachedConfig < God::Behavior
2
+ def before_start
3
+ service = self.watch.name[/^(\w+)-?/, 1]
4
+ memcache_dir = File.join(MONITOR_PATH, service)
5
+
6
+ memcache_script = File.join(memcache_dir, service)
7
+ unless File.exists? memcache_script
8
+ FileUtils.mkdir_p memcache_dir unless File.exists? memcache_dir
9
+ CLUSTER.retrieve service, service, memcache_file
10
+ end
11
+
12
+ if File.exists? memcache_file
13
+ system "cd #{memcache_dir} && source #{memcache_file}"
14
+ end
15
+ end
16
+
17
+ def after_stop
18
+ service = self.watch.name[/^(\w+)-?/, 1]
19
+ CLUSTER.current('disable', service)
20
+ end
21
+ end
22
+
23
+ God.watch do |w|
24
+ w.name = 'memcache'
25
+ w.interval = 120.seconds
26
+ memcache_script = File.join(MONITOR_PATH, 'memcache', 'memcached')
27
+
28
+ w.behavior(:memcache_config)
29
+ w.behavior(:clear_pid_file)
30
+
31
+ w.start = memcache_script
32
+ w.stop = 'killall memcached'
33
+
34
+ w.transition([:start, :restart], :up) {|on|
35
+ on.condition(:process_running) {|c|
36
+ c.running = true
37
+ c.notify = 'simon'
38
+ }
39
+
40
+ on.condition(:tries) {|c|
41
+ c.times = 5
42
+ c.transition = :start
43
+ }
44
+ }
45
+
46
+ w.transition(:up, :start) {|on|
47
+ on.condition(:process_exits) {|c|
48
+ c.notify = 'simon'
49
+ }
50
+ }
51
+
52
+
53
+ w.lifecycle {|on|
54
+ on.condition(:flapping) {|c|
55
+ c.to_state = [:start, :restart]
56
+ c.times = 5
57
+ c.within = 5.minutes
58
+ c.transition = :unmonitored
59
+ c.retry_in = 10.minutes
60
+ c.retry_times = 5
61
+ c.retry_within = 2.hours
62
+ }
63
+ }
64
+ end
@@ -0,0 +1,12 @@
1
+ #!/bin/sh
2
+ creds="/home/${USER:-app}/.cluster/credentials.yml"
3
+ if [[ -e $creds ]]; then
4
+ machine=`cluster -c${creds} current dns`
5
+ fi
6
+
7
+ if [[ $machine == '' ]]; then
8
+ machine=`hostname -f`
9
+ fi
10
+ pid=/home/${USER:-app}/checkpoint/shared/pids
11
+ /usr/bin/memcached -d -P $pid -m 600 -l $machine
12
+ cluster current enable memcache
@@ -0,0 +1,55 @@
1
+ # See /usr/share/postfix/main.cf.dist for a commented, more complete version
2
+
3
+ # Debian specific: Specifying a file name will cause the first
4
+ # line of that file to be used as the name. The Debian default
5
+ # is /etc/mailname.
6
+ #myorigin = /etc/mailname
7
+
8
+ smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
9
+ biff = no
10
+
11
+ # appending .domain is the MUA's job.
12
+ append_dot_mydomain = no
13
+
14
+ # Uncomment the next line to generate "delayed mail" warnings
15
+ #delay_warning_time = 4h
16
+
17
+ readme_directory = no
18
+
19
+ # TLS parameters
20
+ smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
21
+ smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
22
+ smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
23
+ smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
24
+
25
+ # See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
26
+ # information on enabling SSL in the smtp client.
27
+
28
+ myhostname = domU-12-31-38-06-C0-72.compute-1.internal
29
+ alias_maps = hash:/etc/aliases
30
+ alias_database = hash:/etc/aliases
31
+ myorigin = /etc/mailname
32
+ mydestination =
33
+ relayhost = [smtp.gmail.com]:587
34
+ #mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
35
+
36
+ # FIXME this should be reset automatically using
37
+ #mynetworks = hash:/etc/postfix/network_table
38
+ mynetworks_style = class
39
+ mailbox_size_limit = 0
40
+ recipient_delimiter = +
41
+ inet_interfaces = all
42
+ default_transport = smtp
43
+ relay_transport = smtp
44
+ inet_protocols = all
45
+
46
+ # Added for sasl / gmail forwarding
47
+ # smtpd_tls_auth_only was changed from yes (and above)
48
+ smtpd_tls_auth_only = no
49
+ smtpd_use_tls=no
50
+ smtp_use_tls = yes
51
+ smtp_sasl_auth_enable = yes
52
+ smtp_sasl_password_maps = hash:/etc/postfix/sasl/passwd
53
+ smtp_sasl_security_options = noanonymous
54
+ smtp_sasl_tls_security_options = noanonymous
55
+ smtp_tls_CAfile = /etc/postfix/cacerts.pem
@@ -0,0 +1,29 @@
1
+ <VirtualHost *:3080>
2
+ ServerAdmin system@checkpoint.com
3
+ ServerName www.checkpointevents.com
4
+ ServerAlias *.checkpointevents.com
5
+
6
+ DocumentRoot /home/app/checkpoint/current/public
7
+ <Directory />
8
+ Options FollowSymLinks
9
+ AllowOverride None
10
+ </Directory>
11
+ <Directory /home/app/checkpoint/current/public>
12
+ Options Indexes FollowSymLinks MultiViews
13
+ AllowOverride All
14
+ Order allow,deny
15
+ allow from all
16
+ </Directory>
17
+
18
+ ErrorDocument 503 /system/maintenance.html
19
+ RewriteEngine On
20
+ RewriteCond %{REQUEST_URI} !.(css|gif|jpg|png)$
21
+ RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
22
+ RewriteCond %{SCRIPT_FILENAME} !maintenance.html
23
+ RewriteRule ^.*$ - [redirect=503,last]
24
+
25
+ LogLevel warn
26
+
27
+ ErrorLog /home/app/checkpoint/shared/log/balanced_error.log
28
+ CustomLog /home/app/checkpoint/shared/log/balanced_access.log combined
29
+ </VirtualHost>
@@ -0,0 +1,20 @@
1
+ #!/bin/bash
2
+
3
+ CONF=/etc/apache2
4
+
5
+ cp ports.conf $CONF
6
+ cp envvars $CONF
7
+ cp redirect $CONF/sites-available
8
+ cp balanced $CONF/sites-available
9
+ cp php.ini /etc/php5/apache2/php.ini
10
+
11
+ cd $CONF/sites-enabled
12
+ rm *
13
+ ln -sf ../sites-available/redirect 900-redirect
14
+ ln -sf ../sites-available/staging 250-staging
15
+ ln -sf ../sites-available/balanced 299-balanced
16
+
17
+ cd $CONF/mods-enabled
18
+ ln -sf ../mods-available/rewrite.load .
19
+ ln -sf ../mods-available/php5.load .
20
+ ln -sf ../mods-available/php5.conf .
@@ -0,0 +1,18 @@
1
+ # envvars - default environment variables for apache2ctl
2
+
3
+ # Since there is no sane way to get the parsed apache2 config in scripts, some
4
+ # settings are defined via environment variables and then used in apache2ctl,
5
+ # /etc/init.d/apache2, /etc/logrotate.d/apache2, etc.
6
+ export APACHE_RUN_USER=www-data
7
+ export APACHE_RUN_GROUP=www-data
8
+ export APACHE_PID_FILE=/var/run/apache2.pid
9
+
10
+ ## The locale used by some modules like mod_dav
11
+ export LANG=C
12
+ ## Uncomment the following line to use the system default locale instead:
13
+ #. /etc/default/locale
14
+
15
+ export LANG
16
+ export CLUSTER_DB=`/var/lib/gems/1.8/bin/cluster -c/home/staging/.cluster/credentials.yml service -d database`
17
+ export CLUSTER_MEMCACHE=`/var/lib/gems/1.8/bin/cluster -c/home/staging/.cluster/credentials.yml services -d memcache`
18
+ export CLUSTER_SMTP=`/var/lib/gems/1.8/bin/cluster -c/home/staging/.cluster/credentials.yml service -d smtp`