poolparty 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/Manifest +55 -0
- data/README.txt +113 -0
- data/Rakefile +18 -0
- data/bin/instance +54 -0
- data/bin/pool +33 -0
- data/config/config.yml +23 -0
- data/config/create_proxy_ami.sh +582 -0
- data/config/haproxy.conf +29 -0
- data/config/heartbeat.conf +9 -0
- data/config/heartbeat_authkeys.conf +2 -0
- data/config/monit/haproxy.monit.conf +7 -0
- data/config/monit/nginx.monit.conf +0 -0
- data/config/monit.conf +8 -0
- data/config/nginx.conf +24 -0
- data/lib/core/array.rb +10 -0
- data/lib/core/exception.rb +9 -0
- data/lib/core/kernel.rb +9 -0
- data/lib/core/module.rb +22 -0
- data/lib/core/object.rb +14 -0
- data/lib/core/string.rb +49 -0
- data/lib/core/time.rb +41 -0
- data/lib/modules/callback.rb +55 -0
- data/lib/modules/ec2_wrapper.rb +74 -0
- data/lib/modules/safe_instance.rb +31 -0
- data/lib/pool_party/application.rb +133 -0
- data/lib/pool_party/init.rb +4 -0
- data/lib/pool_party/master.rb +189 -0
- data/lib/pool_party/monitors/cpu.rb +18 -0
- data/lib/pool_party/monitors/memory.rb +21 -0
- data/lib/pool_party/monitors/web.rb +18 -0
- data/lib/pool_party/monitors.rb +13 -0
- data/lib/pool_party/optioner.rb +16 -0
- data/lib/pool_party/os/ubuntu.rb +78 -0
- data/lib/pool_party/os.rb +11 -0
- data/lib/pool_party/remote_instance.rb +180 -0
- data/lib/pool_party/remoting.rb +112 -0
- data/lib/pool_party/scheduler.rb +93 -0
- data/lib/pool_party/tasks.rb +220 -0
- data/lib/pool_party.rb +69 -0
- data/lib/s3/s3_object_store_folders.rb +44 -0
- data/poolparty.gemspec +55 -0
- data/spec/application_spec.rb +32 -0
- data/spec/callback_spec.rb +65 -0
- data/spec/helpers/ec2_mock.rb +56 -0
- data/spec/helpers/remote_instance_mock.rb +11 -0
- data/spec/kernel_spec.rb +11 -0
- data/spec/master_spec.rb +147 -0
- data/spec/monitor_spec.rb +16 -0
- data/spec/optioner_spec.rb +22 -0
- data/spec/poolparty_spec.rb +8 -0
- data/spec/remote_instance_spec.rb +29 -0
- data/spec/remoting_spec.rb +75 -0
- data/spec/spec_helper.rb +38 -0
- data/spec/string_spec.rb +28 -0
- data/test/test_pool_party.rb +0 -0
- metadata +171 -0
data/CHANGELOG
ADDED
data/Manifest
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
bin/instance
|
2
|
+
bin/pool
|
3
|
+
CHANGELOG
|
4
|
+
config/config.yml
|
5
|
+
config/create_proxy_ami.sh
|
6
|
+
config/haproxy.conf
|
7
|
+
config/heartbeat.conf
|
8
|
+
config/heartbeat_authkeys.conf
|
9
|
+
config/monit/haproxy.monit.conf
|
10
|
+
config/monit/nginx.monit.conf
|
11
|
+
config/monit.conf
|
12
|
+
config/nginx.conf
|
13
|
+
lib/core/array.rb
|
14
|
+
lib/core/exception.rb
|
15
|
+
lib/core/kernel.rb
|
16
|
+
lib/core/module.rb
|
17
|
+
lib/core/object.rb
|
18
|
+
lib/core/string.rb
|
19
|
+
lib/core/time.rb
|
20
|
+
lib/modules/callback.rb
|
21
|
+
lib/modules/ec2_wrapper.rb
|
22
|
+
lib/modules/safe_instance.rb
|
23
|
+
lib/pool_party/application.rb
|
24
|
+
lib/pool_party/init.rb
|
25
|
+
lib/pool_party/master.rb
|
26
|
+
lib/pool_party/monitors/cpu.rb
|
27
|
+
lib/pool_party/monitors/memory.rb
|
28
|
+
lib/pool_party/monitors/web.rb
|
29
|
+
lib/pool_party/monitors.rb
|
30
|
+
lib/pool_party/optioner.rb
|
31
|
+
lib/pool_party/os/ubuntu.rb
|
32
|
+
lib/pool_party/os.rb
|
33
|
+
lib/pool_party/remote_instance.rb
|
34
|
+
lib/pool_party/remoting.rb
|
35
|
+
lib/pool_party/scheduler.rb
|
36
|
+
lib/pool_party/tasks.rb
|
37
|
+
lib/pool_party.rb
|
38
|
+
lib/s3/s3_object_store_folders.rb
|
39
|
+
Manifest
|
40
|
+
Rakefile
|
41
|
+
README.txt
|
42
|
+
spec/application_spec.rb
|
43
|
+
spec/callback_spec.rb
|
44
|
+
spec/helpers/ec2_mock.rb
|
45
|
+
spec/helpers/remote_instance_mock.rb
|
46
|
+
spec/kernel_spec.rb
|
47
|
+
spec/master_spec.rb
|
48
|
+
spec/monitor_spec.rb
|
49
|
+
spec/optioner_spec.rb
|
50
|
+
spec/poolparty_spec.rb
|
51
|
+
spec/remote_instance_spec.rb
|
52
|
+
spec/remoting_spec.rb
|
53
|
+
spec/spec_helper.rb
|
54
|
+
spec/string_spec.rb
|
55
|
+
test/test_pool_party.rb
|
data/README.txt
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
= PoolParty
|
2
|
+
http://poolpartyrb.com
|
3
|
+
Ari Lerner
|
4
|
+
CitrusByte
|
5
|
+
http://blog.citrusbyte.com
|
6
|
+
|
7
|
+
== DESCRIPTION:
|
8
|
+
|
9
|
+
* Pool Party (http://poolpartyrb.com), Ari Lerner (http://blog.xnot.org, http://blog.citrusbyte.com) - Pool Party is a framework for maintaining and running auto-scalable applications on Amazon's EC2 cloud. Run entire applications using the EC2 cluster and the unlimited S3 disk. More details to be listed at http://poolpartyrb.com.
|
10
|
+
|
11
|
+
== Basics
|
12
|
+
|
13
|
+
Pool Party is written with the intention of being as application-agnostic as possible. It installs only the basic required software to glue the cloud together on the instances as listed below.
|
14
|
+
|
15
|
+
Pool Party is easily configuration. In fact, it makes little assumptions about your development environment and allows several options on how to begin configuring the cloud.
|
16
|
+
|
17
|
+
= Development setup
|
18
|
+
# IN THE ENVIRONMENT
|
19
|
+
There are 5 values that pool party reads from the environment, you can set these basic environment variables and leave the rest to the pool party defaults. Those values are:
|
20
|
+
ENV["ACCESS_KEY"] => AWS access key
|
21
|
+
ENV["SECRET_ACCESS_KEY"] => AWS secret access key
|
22
|
+
ENV["CONFIG_FILE"] => Location of your config yaml file (optional)
|
23
|
+
ENV["EC2_HOME"] => EC2 home directory (defaults to ~/.ec2)
|
24
|
+
ENV["KEYPAIR_NAME"] => The keypair used to launch instances
|
25
|
+
The structure assumed for the keypair is EC2_HOME/id_rsa-<keypairname>
|
26
|
+
|
27
|
+
# IN A CONFIG FILE
|
28
|
+
PoolParty assumes your config directory is set in config/config.yml. However, you can set this in your environment variables and it will read the config file from the environment variable
|
29
|
+
|
30
|
+
# WITH A RAKE TASK
|
31
|
+
PoolParty comes with a rake task that can setup your environment for you. Set the environment variables above and run
|
32
|
+
rake dev:setup
|
33
|
+
This will write a .<KEYPAIR_NAME>_pool_keys into your home directory. Then you can just run
|
34
|
+
source ~/.<KEYPAIR_NAME>_pool_keys
|
35
|
+
and your environment will be all setup for you everytime you want to work on the cloud
|
36
|
+
|
37
|
+
= Basics
|
38
|
+
PoolParty can work in two ways to load balance it's traffic. It can either do server-side or client-side load-balancing. Since every instance load balances itself, you can either set the client to grab an instance and send it to that using client-side load balancing (with a js library). Alternatively, you can set the master in dns and reference it when referring to the application.
|
39
|
+
Since PoolParty makes no assumptions as to what you will be hosting on the application, the world is your oyster when running a cloud. You can set each instance to register with a dynDNS service so that your application has multiple points of entry and can run load-balanced on the fly.
|
40
|
+
Every instance will auto-mount the s3 bucket set in the config file (if it is set up) into the /data folder of the instance. This gives each instance access to the same data regardless of the instance. It uses s3fuse and caching through s3fuse in the /tmp directory to work as fast as possible on the local instances.
|
41
|
+
The instances all are loaded with the following software:
|
42
|
+
Haproxy - The basic load balancing software
|
43
|
+
Heartbeat - The failover software
|
44
|
+
S3Fuse - The mounting software for the s3 bucket
|
45
|
+
Monit - The maintainer of the services to maintain services
|
46
|
+
|
47
|
+
When an instance is started or brought down, the master is responsible for reloading every instance with the new data on each instance. If the master goes down, the next in succession will take over as the master (using heartbeat) and it will reconfigure the cloud, setting itself as the master and take over the maintenance of the cloud.
|
48
|
+
|
49
|
+
Each instance has a /etc/hosts file that has each node listed as the node name listed in the cloud:list (rake task).
|
50
|
+
|
51
|
+
= Cloud tools
|
52
|
+
The cloud can be maintained entirely through rake tasks, although there are a few front-ends being developed (one in cocoa).
|
53
|
+
All the cloud rake tasks are in the cloud namespace and are:
|
54
|
+
rake cloud:deploy # Deploy web application from production git repos spe...
|
55
|
+
rake cloud:list # List cloud
|
56
|
+
rake cloud:maintain # Maintain the cloud (run on the master)
|
57
|
+
rake cloud:prepare # Prepare all servers
|
58
|
+
rake cloud:reload # Reload all instances with updated data
|
59
|
+
rake cloud:shutdown # Shutdown the entire cloud
|
60
|
+
rake cloud:start # Start the cloud
|
61
|
+
|
62
|
+
The instance rake tasks are in the instance namespace
|
63
|
+
rake instance:configure # Configure the stack on this node
|
64
|
+
rake instance:exec # Execute cmd on a remote instance
|
65
|
+
rake instance:install # Install stack on this node
|
66
|
+
rake instance:load # Start all services
|
67
|
+
rake instance:reload # Restart all the services
|
68
|
+
rake instance:scp # Send a file to the remote instance
|
69
|
+
rake instance:shutdown # Teardown instance
|
70
|
+
rake instance:ssh # Remotely login to the remote instance
|
71
|
+
rake instance:stop # Stop all services
|
72
|
+
|
73
|
+
For more help, check http://poolpartyrb.com
|
74
|
+
|
75
|
+
== REQUIREMENTS:
|
76
|
+
* yaml
|
77
|
+
* aws/s3
|
78
|
+
* aska
|
79
|
+
* EC2
|
80
|
+
* fastthread
|
81
|
+
|
82
|
+
== INSTALL:
|
83
|
+
|
84
|
+
gem install pool_party
|
85
|
+
|
86
|
+
== ROADMAP
|
87
|
+
* v0.1.0 - Add SQS task support
|
88
|
+
* v0.2.0 - Callback support
|
89
|
+
|
90
|
+
== LICENSE:
|
91
|
+
|
92
|
+
(The MIT License)
|
93
|
+
|
94
|
+
Copyright (c) 2008 Ari Lerner. CitrusByte
|
95
|
+
|
96
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
97
|
+
a copy of this software and associated documentation files (the
|
98
|
+
'Software'), to deal in the Software without restriction, including
|
99
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
100
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
101
|
+
permit persons to whom the Software is furnished to do so, subject to
|
102
|
+
the following conditions:
|
103
|
+
|
104
|
+
The above copyright notice and this permission notice shall be
|
105
|
+
included in all copies or substantial portions of the Software.
|
106
|
+
|
107
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
108
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
109
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
110
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
111
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
112
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
113
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'echoe'
|
3
|
+
require 'lib/pool_party'
|
4
|
+
|
5
|
+
task :default => :test
|
6
|
+
|
7
|
+
Echoe.new("poolparty") do |p|
|
8
|
+
p.author = "Ari Lerner"
|
9
|
+
p.email = "ari.lerner@citrusbyte.com"
|
10
|
+
p.summary = "Run your entire application off EC2, managed and auto-scaling"
|
11
|
+
p.url = "http://blog.citrusbyte.com"
|
12
|
+
p.docs_host = "www.poolpartyrb.com"
|
13
|
+
p.dependencies = %w(aws-s3 amazon-ec2 aska)
|
14
|
+
p.install_message = "For more information, check http://poolpartyrb.com\n*** Ari Lerner @ <ari.lerner@citrusbyte.com> ***"
|
15
|
+
p.include_rakefile = true
|
16
|
+
end
|
17
|
+
|
18
|
+
PoolParty::Tasks.new
|
data/bin/instance
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'optparse'
|
4
|
+
require 'pool_party'
|
5
|
+
|
6
|
+
# Set defaults
|
7
|
+
list = PoolParty::Optioner.parse(ARGV.dup)
|
8
|
+
options = PoolParty::Application.options(ARGV.dup)
|
9
|
+
master = PoolParty::Master.new
|
10
|
+
|
11
|
+
instance_options = {
|
12
|
+
:instance_number => 0,
|
13
|
+
:cmd => "ls -l",
|
14
|
+
:src => "",
|
15
|
+
:dest => ""
|
16
|
+
}
|
17
|
+
OptionParser.new do |op|
|
18
|
+
op.on('-i inst', '--instance i', "The instance_number (default: 0)") {|x| instance_options[:instance_number] = x}
|
19
|
+
op.on('-C cmd', '--command command', "Run this command on the instance (default: 'ls -l')") {|x| instance_options[:cmd] = x}
|
20
|
+
op.on('-s src', '--source filename', "Send this file through scp (default: '')") {|x| instance_options[:src] = x}
|
21
|
+
op.on('-d dest', '--destination filename', "Send file to (default: '')") {|x| instance_options[:dest] = x}
|
22
|
+
end.parse!(ARGV.dup)
|
23
|
+
|
24
|
+
instance = master.get_node(instance_options[:instance_number])
|
25
|
+
|
26
|
+
unless instance
|
27
|
+
puts "Cloud is not running"
|
28
|
+
exit
|
29
|
+
end
|
30
|
+
|
31
|
+
case list[0]
|
32
|
+
when "ssh"
|
33
|
+
PoolParty.message "Ssh'ing into #{instance.ip}"
|
34
|
+
instance.ssh
|
35
|
+
when "cmd"
|
36
|
+
PoolParty.message "Executing #{instance_options[:cmd]} on #{instance.ip}"
|
37
|
+
instance.ssh instance_options[:cmd]
|
38
|
+
when "scp"
|
39
|
+
instance.scp instance_options[:src], instance_options[:dest]
|
40
|
+
when "restart"
|
41
|
+
message "Restarting services"
|
42
|
+
instance.restart_with_monit
|
43
|
+
when "start"
|
44
|
+
message "Starting services"
|
45
|
+
instance.start_with_monit
|
46
|
+
when "stop"
|
47
|
+
message "Stopping services"
|
48
|
+
instance.stop_with_monit
|
49
|
+
when "install"
|
50
|
+
message "Installing services"
|
51
|
+
instance.install_stack
|
52
|
+
else
|
53
|
+
puts master.list
|
54
|
+
end
|
data/bin/pool
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'pool_party'
|
4
|
+
|
5
|
+
# Set defaults
|
6
|
+
list = PoolParty::Optioner.parse(ARGV.dup)
|
7
|
+
options = PoolParty::Application.options(ARGV.dup)
|
8
|
+
master = PoolParty::Master.new
|
9
|
+
|
10
|
+
# if list.empty?
|
11
|
+
# puts "Usage: pool [options] {start|stop|list|maintain}"
|
12
|
+
# exit
|
13
|
+
# end
|
14
|
+
|
15
|
+
case list[0]
|
16
|
+
when "start"
|
17
|
+
PoolParty.message "Starting cloud"
|
18
|
+
master.start_cloud!
|
19
|
+
when "stop"
|
20
|
+
PoolParty.message "Stopping cloud"
|
21
|
+
master.request_termination_of_all_instances
|
22
|
+
when "list"
|
23
|
+
puts master.list
|
24
|
+
when "maintain"
|
25
|
+
PoolParty.message "Maintaining cloud"
|
26
|
+
master.start_monitor!
|
27
|
+
when "restart"
|
28
|
+
PoolParty.message "Restarting cloud"
|
29
|
+
master.request_termination_of_all_instances
|
30
|
+
master.start_cloud!
|
31
|
+
else
|
32
|
+
puts master.list
|
33
|
+
end
|
data/config/config.yml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
:app_name: "test_app"
|
2
|
+
:user_id: "1619-6456-1164"
|
3
|
+
:access_key: "1XCTNEK1CC5BQPA3EE02"
|
4
|
+
:secret_access_key: "Q2qJHP0S2iOKikn9glB+KZcF/aYf4huS/GdHvqEZ"
|
5
|
+
:ami: "ami-4f7a9f26"
|
6
|
+
:size: small
|
7
|
+
:polling_time: "30.seconds"
|
8
|
+
:minimum_instances: 1
|
9
|
+
:maximum_instances: 3
|
10
|
+
:ec2_dir: "/Users/auser/.ec2"
|
11
|
+
:keypair: auser
|
12
|
+
:os: ubuntu
|
13
|
+
:host_port: 80
|
14
|
+
:client_port: 8001
|
15
|
+
:shared_bucket: "pool-party-app-data"
|
16
|
+
:services: nginx
|
17
|
+
:environment: production
|
18
|
+
:expand_when:
|
19
|
+
web_requests < 10
|
20
|
+
cpu_usage < 0.2
|
21
|
+
:contract_when:
|
22
|
+
cpu_usage > 0.15
|
23
|
+
web_requests > 1.5
|