wakame 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +8 -0
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/app_generators/wakame/templates/cluster/resources/markers/http_application_server.rb +3 -0
- data/app_generators/wakame/templates/cluster/resources/markers/http_asset_server.rb +2 -0
- data/app_generators/wakame/templates/cluster/resources/markers/http_server.rb +9 -0
- data/app_generators/wakame/templates/config/cluster.rb +36 -99
- data/app_generators/wakame/templates/config/init.d/wakame-agent +3 -3
- data/app_generators/wakame/templates/config/init.d/wakame-master +3 -3
- data/app_generators/wakame/wakame_generator.rb +5 -1
- data/contrib/imagesetup.sh +9 -5
- data/lib/ext/uri.rb +13 -0
- data/lib/wakame/action.rb +46 -21
- data/lib/wakame/{rule_engine.rb → action_manager.rb} +148 -36
- data/lib/wakame/actions/deploy_config.rb +35 -0
- data/lib/wakame/actions/launch_cluster.rb +8 -10
- data/lib/wakame/actions/launch_vm.rb +26 -20
- data/lib/wakame/actions/migrate_service.rb +30 -19
- data/lib/wakame/actions/notify_child_changed.rb +34 -0
- data/lib/wakame/actions/notify_parent_changed.rb +34 -0
- data/lib/wakame/actions/propagate_resource.rb +27 -0
- data/lib/wakame/actions/propagate_service.rb +27 -0
- data/lib/wakame/actions/reload_service.rb +21 -9
- data/lib/wakame/actions/shutdown_cluster.rb +3 -3
- data/lib/wakame/actions/shutdown_vm.rb +14 -5
- data/lib/wakame/actions/start_service.rb +53 -47
- data/lib/wakame/actions/stop_service.rb +35 -23
- data/lib/wakame/actor/system.rb +6 -3
- data/lib/wakame/agent.rb +29 -7
- data/lib/wakame/amqp_client.rb +26 -5
- data/lib/wakame/command/action_status.rb +7 -7
- data/lib/wakame/command/actor.rb +10 -10
- data/lib/wakame/command/import_cluster_config.rb +10 -0
- data/lib/wakame/command/launch_cluster.rb +2 -2
- data/lib/wakame/command/launch_vm.rb +3 -3
- data/lib/wakame/command/migrate_service.rb +7 -7
- data/lib/wakame/command/propagate_resource.rb +42 -0
- data/lib/wakame/command/propagate_service.rb +21 -19
- data/lib/wakame/command/reload_service.rb +3 -13
- data/lib/wakame/command/shutdown_cluster.rb +2 -2
- data/lib/wakame/command/start_service.rb +14 -0
- data/lib/wakame/command/status.rb +32 -10
- data/lib/wakame/command/stop_service.rb +27 -21
- data/lib/wakame/command.rb +19 -3
- data/lib/wakame/command_queue.rb +87 -67
- data/lib/wakame/configuration.rb +6 -0
- data/lib/wakame/event.rb +17 -0
- data/lib/wakame/event_dispatcher.rb +32 -23
- data/lib/wakame/graph.rb +2 -1
- data/lib/wakame/initializer.rb +11 -8
- data/lib/wakame/master.rb +327 -209
- data/lib/wakame/monitor/agent.rb +5 -1
- data/lib/wakame/monitor/service.rb +6 -5
- data/lib/wakame/packets.rb +13 -21
- data/lib/wakame/runner/administrator_command.rb +383 -264
- data/lib/wakame/runner/agent.rb +1 -5
- data/lib/wakame/runner/master.rb +0 -3
- data/lib/wakame/service.rb +817 -538
- data/lib/wakame/status_db.rb +383 -0
- data/lib/wakame/template.rb +27 -130
- data/lib/wakame/trigger.rb +10 -18
- data/lib/wakame/triggers/instance_count_update.rb +1 -1
- data/lib/wakame/triggers/load_history.rb +1 -1
- data/lib/wakame/triggers/maintain_ssh_known_hosts.rb +8 -5
- data/lib/wakame/triggers/shutdown_unused_vm.rb +1 -1
- data/lib/wakame/util.rb +64 -55
- data/lib/wakame.rb +4 -0
- data/tests/test_action_manager.rb +111 -0
- data/tests/test_service.rb +128 -23
- data/tests/test_status_db.rb +82 -0
- data/tests/test_uri_amqp.rb +10 -0
- data/wakame_generators/resource/templates/apache_app/apache_app.rb +19 -18
- data/wakame_generators/resource/templates/apache_app/conf/apache2.conf +14 -2
- data/wakame_generators/resource/templates/apache_app/conf/system-app.conf +1 -1
- data/wakame_generators/resource/templates/apache_app/conf/vh/aaa.test.conf +9 -0
- data/wakame_generators/resource/templates/apache_lb/apache_lb.rb +21 -20
- data/wakame_generators/resource/templates/apache_lb/conf/apache2.conf +14 -2
- data/wakame_generators/resource/templates/apache_lb/conf/system-lb.conf +17 -2
- data/wakame_generators/resource/templates/apache_lb/conf/vh/aaa.test.conf +37 -0
- data/wakame_generators/resource/templates/apache_www/apache_www.rb +20 -18
- data/wakame_generators/resource/templates/apache_www/conf/apache2.conf +14 -2
- data/wakame_generators/resource/templates/apache_www/conf/system-www.conf +1 -1
- data/wakame_generators/resource/templates/apache_www/conf/vh/aaa.test.conf +9 -0
- data/wakame_generators/resource/templates/ec2_elastic_ip/ec2_elastic_ip.rb +6 -8
- data/wakame_generators/resource/templates/ec2_elb/ec2_elb.rb +7 -6
- data/wakame_generators/resource/templates/memcached/conf/memcached.conf +47 -0
- data/wakame_generators/resource/templates/memcached/init.d/memcached +61 -0
- data/wakame_generators/resource/templates/memcached/memcached.rb +73 -0
- data/wakame_generators/resource/templates/mysql_master/conf/my.cnf +5 -7
- data/wakame_generators/resource/templates/mysql_master/mysql_master.rb +35 -34
- data/wakame_generators/resource/templates/mysql_slave/conf/my.cnf +6 -6
- data/wakame_generators/resource/templates/mysql_slave/mysql_slave.rb +21 -24
- data/wakame_generators/resource/templates/nginx/conf/nginx.conf +17 -27
- data/wakame_generators/resource/templates/nginx/conf/vh/aaa.test.conf +30 -0
- data/wakame_generators/resource/templates/nginx/nginx.rb +18 -18
- metadata +34 -21
- data/lib/wakame/actions/propagate_instances.rb +0 -70
- data/lib/wakame/manager/commands.rb +0 -134
- data/lib/wakame/rule.rb +0 -116
- data/lib/wakame/triggers/process_command.rb +0 -41
- data/tests/test_rule_engine.rb +0 -127
- data/wakame_generators/resource/templates/apache_app/conf/sites-app.conf +0 -23
- data/wakame_generators/resource/templates/apache_lb/conf/sites-lb.conf +0 -54
- data/wakame_generators/resource/templates/apache_www/conf/sites-www.conf +0 -23
@@ -36,7 +36,7 @@ LoadModule info_module /usr/lib/apache2/modules/mod_info.so
|
|
36
36
|
LoadModule passenger_module /usr/local/gems/gems/passenger-2.2.1/ext/apache2/mod_passenger.so
|
37
37
|
|
38
38
|
### Port configuration
|
39
|
-
Listen <%=
|
39
|
+
Listen <%= resource.listen_port %>
|
40
40
|
|
41
41
|
#<IfModule mod_ssl.c>
|
42
42
|
# Listen 443
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<VirtualHost *:<%= resource.listen_port %>>
|
2
|
+
ServerName aaa.test
|
3
|
+
DocumentRoot /home/wakame/apps/development/test/public
|
4
|
+
RailsEnv development
|
5
|
+
|
6
|
+
LogLevel warn
|
7
|
+
CustomLog /var/log/apache2/access-app.log combined
|
8
|
+
ErrorLog /var/log/apache2/error-app.log
|
9
|
+
</VirtualHost>
|
@@ -1,34 +1,35 @@
|
|
1
|
-
|
2
|
-
require 'wakame/rule'
|
3
|
-
|
4
1
|
class Apache_LB < Wakame::Service::Resource
|
5
|
-
include
|
6
|
-
include Wakame::Service::ApacheBasicProps
|
2
|
+
include HttpServer
|
7
3
|
|
8
|
-
|
9
|
-
|
4
|
+
property :listen_port, {:default=>80}
|
5
|
+
property :listen_port_https, {:default=>443}
|
10
6
|
|
11
7
|
def render_config(template)
|
12
|
-
template.
|
13
|
-
|
8
|
+
template.glob_basedir(%w(conf/envvars-lb init.d/apache2-lb)) { |d|
|
9
|
+
template.cp(d)
|
10
|
+
}
|
11
|
+
template.glob_basedir(%w(conf/system-lb.conf conf/apache2.conf conf/vh/*.conf)) { |d|
|
12
|
+
template.render(d)
|
13
|
+
}
|
14
14
|
template.chmod("init.d/apache2-lb", 0755)
|
15
15
|
end
|
16
16
|
|
17
17
|
def on_parent_changed(svc, action)
|
18
|
-
Wakame::
|
18
|
+
action.trigger_action(Wakame::Actions::DeployConfig.new(svc))
|
19
|
+
action.flush_subactions
|
19
20
|
reload(svc, action)
|
20
21
|
end
|
21
22
|
|
22
23
|
def start(svc, action)
|
23
24
|
cond = ConditionalWait.new { |cond|
|
24
25
|
cond.wait_event(Wakame::Event::ServiceOnline) { |event|
|
25
|
-
event.instance_id == svc.
|
26
|
+
event.instance_id == svc.id
|
26
27
|
}
|
27
28
|
}
|
28
29
|
|
29
|
-
request = action.actor_request(svc.
|
30
|
-
'/service_monitor/register', svc.
|
31
|
-
action.actor_request(svc.
|
30
|
+
request = action.actor_request(svc.cloud_host.agent_id,
|
31
|
+
'/service_monitor/register', svc.id, :pidfile, '/var/run/apache2-lb.pid').request
|
32
|
+
action.actor_request(svc.cloud_host.agent_id,
|
32
33
|
'/daemon/start', "apache_lb", 'init.d/apache2-lb'){ |req|
|
33
34
|
req.wait
|
34
35
|
Wakame.log.debug("#{self.class} process started")
|
@@ -40,11 +41,11 @@ class Apache_LB < Wakame::Service::Resource
|
|
40
41
|
def stop(svc, action)
|
41
42
|
cond = ConditionalWait.new { |cond|
|
42
43
|
cond.wait_event(Wakame::Event::ServiceOffline) { |event|
|
43
|
-
event.instance_id == svc.
|
44
|
+
event.instance_id == svc.id
|
44
45
|
}
|
45
46
|
}
|
46
47
|
|
47
|
-
action.actor_request(svc.
|
48
|
+
action.actor_request(svc.cloud_host.agent_id,
|
48
49
|
'/daemon/stop', 'apache_lb', 'init.d/apache2-lb'){ |req|
|
49
50
|
req.wait
|
50
51
|
Wakame.log.debug("#{self.class} process stopped")
|
@@ -52,15 +53,15 @@ class Apache_LB < Wakame::Service::Resource
|
|
52
53
|
|
53
54
|
cond.wait
|
54
55
|
|
55
|
-
request = action.actor_request(svc.
|
56
|
-
'/service_monitor/unregister', svc.
|
56
|
+
request = action.actor_request(svc.cloud_host.agent_id,
|
57
|
+
'/service_monitor/unregister', svc.id ).request
|
57
58
|
end
|
58
59
|
|
59
60
|
def reload(svc, action)
|
60
|
-
action.actor_request(svc.
|
61
|
+
action.actor_request(svc.cloud_host.agent_id,
|
61
62
|
'/daemon/reload', "apache_lb", 'init.d/apache2-lb'){ |req|
|
62
63
|
req.wait
|
63
|
-
Wakame.log.debug("#{self.class} process
|
64
|
+
Wakame.log.debug("#{self.class} process reloaded")
|
64
65
|
}
|
65
66
|
end
|
66
67
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#ServerRoot "/etc/apache2"
|
2
2
|
#ServerRoot "/home/wakame/config/apache2"
|
3
|
-
ServerRoot "<%= agent.root_path %>/tmp/config/apache_lb/conf"
|
3
|
+
ServerRoot "<%= cloud_host.agent.root_path %>/tmp/config/apache_lb/conf"
|
4
4
|
|
5
5
|
LockFile /var/lock/apache2/accept.lock
|
6
6
|
PidFile ${APACHE_PID_FILE}
|
@@ -43,4 +43,16 @@ LogFormat "%{Referer}i -> %U" referer
|
|
43
43
|
LogFormat "%{User-agent}i" agent
|
44
44
|
</IfModule>
|
45
45
|
|
46
|
-
|
46
|
+
NameVirtualHost *:<%= resource.listen_port %>
|
47
|
+
|
48
|
+
# Wild Card Virtual Host
|
49
|
+
#<VirtualHost *:<%= resource.listen_port %>>
|
50
|
+
#DocumentRoot /var/www
|
51
|
+
#
|
52
|
+
#LogLevel warn
|
53
|
+
#CustomLog /var/log/apache2/access-lb.log combined
|
54
|
+
#ErrorLog /var/log/apache2/error-lb.log
|
55
|
+
#
|
56
|
+
#</VirtualHost>
|
57
|
+
|
58
|
+
Include vh/*.conf
|
@@ -40,10 +40,10 @@ LoadModule proxy_balancer_module /usr/lib/apache2/modules/mod_proxy_balancer.so
|
|
40
40
|
|
41
41
|
|
42
42
|
### Port configuration
|
43
|
-
Listen <%=
|
43
|
+
Listen <%= resource.listen_port %>
|
44
44
|
|
45
45
|
<IfModule mod_ssl.c>
|
46
|
-
Listen <%=
|
46
|
+
Listen <%= resource.listen_port_https %>
|
47
47
|
</IfModule>
|
48
48
|
|
49
49
|
|
@@ -73,3 +73,18 @@ Listen <%= property.listen_port %>
|
|
73
73
|
# Allow from 127.0.0.1 localhost.localdomain localhost ip6-localhost
|
74
74
|
#</Location>
|
75
75
|
#</IfModule>
|
76
|
+
|
77
|
+
<Proxy balancer://cluster-www>
|
78
|
+
<%- service_cluster.each_instance(HttpAssetServer) { |n|
|
79
|
+
next if n.status != STATUS_ONLINE
|
80
|
+
-%>
|
81
|
+
BalancerMember http://<%= n.cloud_host.agent_ip %>:<%= n.resource.listen_port %> loadfactor=10
|
82
|
+
<%- } -%>
|
83
|
+
</Proxy>
|
84
|
+
<Proxy balancer://cluster-app>
|
85
|
+
<%- service_cluster.each_instance(HttpApplicationServer) { |n|
|
86
|
+
next if n.status != STATUS_ONLINE
|
87
|
+
-%>
|
88
|
+
BalancerMember http://<%= n.cloud_host.agent_ip %>:<%= n.resource.listen_port %> loadfactor=10
|
89
|
+
<%- } -%>
|
90
|
+
</Proxy>
|
@@ -0,0 +1,37 @@
|
|
1
|
+
<VirtualHost *:<%= resource.listen_port %>>
|
2
|
+
ServerName aaa.test
|
3
|
+
DocumentRoot /var/www/
|
4
|
+
|
5
|
+
LogLevel warn
|
6
|
+
CustomLog /var/log/apache2/aaa.test-access.log combined
|
7
|
+
ErrorLog /var/log/apache2/aaa.test-error.log
|
8
|
+
|
9
|
+
<Location /balancer-manager>
|
10
|
+
SetHandler balancer-manager
|
11
|
+
# Order deny,allow
|
12
|
+
# Deny from all
|
13
|
+
# Allow from 127.0.0.1 localhost.localdomain localhost ip6-localhost
|
14
|
+
</Location>
|
15
|
+
|
16
|
+
ProxyRequests Off
|
17
|
+
ProxyPreserveHost On
|
18
|
+
ProxyPassReverse / balancer://cluster-www/
|
19
|
+
ProxyPassReverse / balancer://cluster-app/
|
20
|
+
|
21
|
+
## Folder based matching
|
22
|
+
#ProxyPassMatch ^(/(images|image|imgs|img|javascripts|javascript|js|stylesheets|css)/.*)$ balancer://cluster-www$1 lbmethod=byrequests timeout=10
|
23
|
+
#Use Proxy to Amazon S3
|
24
|
+
ProxyPassMatch ^(/(images|image|imgs|img|javascripts|javascript|js|stylesheets|css)/.*)$ http://your-bucket.s3.amazonaws.com$1
|
25
|
+
#Use Amazon Cloudfront
|
26
|
+
#RedirectMatch ^(/(images|image|imgs|img|javascripts|javascript|js|stylesheets|css)/.*)$ http://your-bucket.s3.cloudfront.net$1
|
27
|
+
|
28
|
+
## Extension based matching
|
29
|
+
#ProxyPassMatch ^(/.*\.(htm|html|ico|jpg|jpeg|png|gif|swf|txt))$ balancer://cluster-www$1 lbmethod=byrequests timeout=10
|
30
|
+
#Use Proxy to Amazon S3
|
31
|
+
ProxyPassMatch ^(/.*\.(htm|html|ico|jpg|jpeg|png|gif|swf|txt))$ http://your-bucket.s3.amazonaws.com$1
|
32
|
+
#Use Amazon Cloudfront
|
33
|
+
#RedirectMatch ^(/.*\.(htm|html|ico|jpg|jpeg|png|gif|swf|txt))$ http://your-bucket.cloudfront.net$1
|
34
|
+
ProxyPassMatch ^/balancer-manager.* !
|
35
|
+
ProxyPass / balancer://cluster-app/ lbmethod=byrequests timeout=10
|
36
|
+
|
37
|
+
</VirtualHost>
|
@@ -1,26 +1,29 @@
|
|
1
1
|
class Apache_WWW < Wakame::Service::Resource
|
2
|
-
include
|
3
|
-
include
|
2
|
+
include HttpServer
|
3
|
+
include HttpAssetServer
|
4
4
|
|
5
|
-
|
6
|
-
def_attribute :max_instances, {:default=>5}
|
5
|
+
property :listen_port, {:default=>8000}
|
7
6
|
|
8
7
|
def render_config(template)
|
9
|
-
template.
|
10
|
-
|
8
|
+
template.glob_basedir(%w(conf/envvars-www init.d/apache2-www)) { |d|
|
9
|
+
template.cp(d)
|
10
|
+
}
|
11
|
+
template.glob_basedir(%w(conf/system-www.conf conf/apache2.conf conf/vh/*.conf)) { |d|
|
12
|
+
template.render(d)
|
13
|
+
}
|
11
14
|
template.chmod("init.d/apache2-www", 0755)
|
12
15
|
end
|
13
16
|
|
14
17
|
def start(svc, action)
|
15
18
|
cond = ConditionalWait.new { |cond|
|
16
19
|
cond.wait_event(Wakame::Event::ServiceOnline) { |event|
|
17
|
-
event.instance_id == svc.
|
20
|
+
event.instance_id == svc.id
|
18
21
|
}
|
19
22
|
}
|
20
23
|
|
21
|
-
request = action.actor_request(svc.
|
22
|
-
'/service_monitor/register', svc.
|
23
|
-
request = action.actor_request(svc.
|
24
|
+
request = action.actor_request(svc.cloud_host.agent_id,
|
25
|
+
'/service_monitor/register', svc.id, :pidfile, '/var/run/apache2-www.pid').request
|
26
|
+
request = action.actor_request(svc.cloud_host.agent_id,
|
24
27
|
'/daemon/start', "apache_www", 'init.d/apache2-www'){ |req|
|
25
28
|
req.wait
|
26
29
|
Wakame.log.debug("#{self.class} process started")
|
@@ -31,26 +34,25 @@ class Apache_WWW < Wakame::Service::Resource
|
|
31
34
|
def stop(svc, action)
|
32
35
|
cond = ConditionalWait.new { |cond|
|
33
36
|
cond.wait_event(Wakame::Event::ServiceOffline) { |event|
|
34
|
-
event.instance_id == svc.
|
37
|
+
event.instance_id == svc.id
|
35
38
|
}
|
36
39
|
}
|
37
40
|
|
38
|
-
request = action.actor_request(svc.
|
41
|
+
request = action.actor_request(svc.cloud_host.agent_id,
|
39
42
|
'/daemon/stop', 'apache_www', 'init.d/apache2-www'){ |req|
|
40
43
|
req.wait
|
41
44
|
Wakame.log.debug("#{self.class} process stooped")
|
42
45
|
}
|
43
46
|
cond.wait
|
44
47
|
|
45
|
-
request = action.actor_request(svc.
|
46
|
-
'/service_monitor/unregister', svc.
|
48
|
+
request = action.actor_request(svc.cloud_host.agent_id,
|
49
|
+
'/service_monitor/unregister', svc.id ).request
|
47
50
|
end
|
48
51
|
|
49
52
|
def reload(svc, action)
|
50
|
-
action.actor_request(
|
51
|
-
|
52
|
-
|
53
|
-
}
|
53
|
+
request = action.actor_request(svc.cloud_host.agent_id,
|
54
|
+
'/daemon/reload', 'apache_www', 'init.d/apache2-www').request
|
55
|
+
request.wait
|
54
56
|
end
|
55
57
|
|
56
58
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#ServerRoot "/etc/apache2"
|
2
2
|
#ServerRoot "/home/wakame/config/apache2"
|
3
|
-
ServerRoot "<%= agent.root_path %>/tmp/config/apache_www/conf"
|
3
|
+
ServerRoot "<%= cloud_host.agent.root_path %>/tmp/config/apache_www/conf"
|
4
4
|
|
5
5
|
|
6
6
|
LockFile /var/lock/apache2/accept.lock
|
@@ -44,4 +44,16 @@ LogFormat "%{Referer}i -> %U" referer
|
|
44
44
|
LogFormat "%{User-agent}i" agent
|
45
45
|
</IfModule>
|
46
46
|
|
47
|
-
|
47
|
+
NameVirtualHost *:<%= resource.listen_port %>
|
48
|
+
|
49
|
+
# Wild Card Virtual Host
|
50
|
+
#<VirtualHost *:<%= resource.listen_port %>>
|
51
|
+
#DocumentRoot /var/www
|
52
|
+
#
|
53
|
+
#LogLevel warn
|
54
|
+
#CustomLog /var/log/apache2/access-www.log combined
|
55
|
+
#ErrorLog /var/log/apache2/error-www.log
|
56
|
+
#
|
57
|
+
#</VirtualHost>
|
58
|
+
|
59
|
+
Include vh/*.conf
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class Ec2ElasticIp < Wakame::Service::Resource
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
property :elastic_ip
|
4
|
+
property :require_agent, false
|
5
5
|
|
6
6
|
def on_parent_changed(svc, action)
|
7
7
|
start(svc, action)
|
@@ -11,12 +11,10 @@ class Ec2ElasticIp < Wakame::Service::Resource
|
|
11
11
|
require 'right_aws'
|
12
12
|
ec2 = RightAws::Ec2.new(Wakame.config.aws_access_key, Wakame.config.aws_secret_key)
|
13
13
|
|
14
|
-
puts svc.parent_instances.size.to_s
|
15
14
|
a = svc.parent_instances.first
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
ec2.associate_address(a.agent.attr[:instance_id], self.elastic_ip)
|
16
|
+
Wakame.log.info("Associating the Elastic IP #{self.elastic_ip} to #{a.cloud_host.agent.vm_attr[:instance_id]}")
|
17
|
+
ec2.associate_address(a.cloud_host.agent.vm_attr[:instance_id], self.elastic_ip)
|
20
18
|
EM.barrier {
|
21
19
|
svc.update_status(Wakame::Service::STATUS_ONLINE)
|
22
20
|
}
|
@@ -28,8 +26,8 @@ class Ec2ElasticIp < Wakame::Service::Resource
|
|
28
26
|
|
29
27
|
a = svc.parent_instances.first
|
30
28
|
|
31
|
-
|
32
|
-
|
29
|
+
Wakame.log.info("Disassociating the Elastic IP #{self.elastic_ip} from #{a.cloud_host.agent.vm_attr[:instance_id]}")
|
30
|
+
ec2.disassociate_address(self.elastic_ip)
|
33
31
|
EM.barrier {
|
34
32
|
svc.update_status(Wakame::Service::STATUS_OFFLINE)
|
35
33
|
}
|
@@ -1,10 +1,11 @@
|
|
1
1
|
class Ec2ELB < Wakame::Service::Resource
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
property :elb_name
|
4
|
+
property :require_agent, false
|
5
|
+
property :just_unregister_when_stop, false
|
6
6
|
|
7
7
|
def on_parent_changed(svc, action)
|
8
|
+
start(svc, action)
|
8
9
|
end
|
9
10
|
|
10
11
|
def start(svc, action)
|
@@ -12,8 +13,8 @@ class Ec2ELB < Wakame::Service::Resource
|
|
12
13
|
|
13
14
|
parents = svc.parent_instances.dup
|
14
15
|
|
15
|
-
vm_slice_ids = parents.collect{|a| a.agent.
|
16
|
-
av_zones = parents.collect{|a| a.agent.
|
16
|
+
vm_slice_ids = parents.collect{|a| a.cloud_host.agent.vm_attr[:instance_id] }.uniq
|
17
|
+
av_zones = parents.collect{|a| a.cloud_host.agent.vm_attr[:availability_zone] }.uniq
|
17
18
|
Wakame.log.info("Setting up the ELB #{self.elb_name} with #{vm_slice_ids.join(', ')}")
|
18
19
|
begin
|
19
20
|
res = elb.describe_load_balancers(self.elb_name)
|
@@ -47,7 +48,7 @@ class Ec2ELB < Wakame::Service::Resource
|
|
47
48
|
|
48
49
|
if self.just_unregister_when_stop
|
49
50
|
parents = svc.parent_instances.dup
|
50
|
-
vm_slice_ids = parents.collect{|a| a.agent.
|
51
|
+
vm_slice_ids = parents.collect{|a| a.cloud_host.agent.vm_attr[:instance_id] }.uniq
|
51
52
|
Wakame.log.info("Deregistering the VM instances (#{vm_slice_ids.join(', ')}) from ELB #{self.elb_name}")
|
52
53
|
|
53
54
|
elb.deregister_instances_with_load_balancer(self.elb_name, *vm_slice_id)
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# memcached default config file
|
2
|
+
# 2003 - Jay Bonci <jaybonci@debian.org>
|
3
|
+
# This configuration file is read by the start-memcached script provided as
|
4
|
+
# part of the Debian GNU/Linux distribution.
|
5
|
+
|
6
|
+
# Run memcached as a daemon. This command is implied, and is not needed for the
|
7
|
+
# daemon to run. See the README.Debian that comes with this package for more
|
8
|
+
# information.
|
9
|
+
-d
|
10
|
+
|
11
|
+
# Log memcached's output to /var/log/memcached
|
12
|
+
logfile /var/log/memcached.log
|
13
|
+
|
14
|
+
# Be verbose
|
15
|
+
# -v
|
16
|
+
|
17
|
+
# Be even more verbose (print client commands as well)
|
18
|
+
# -vv
|
19
|
+
|
20
|
+
# Start with a cap of 64 megs of memory. It's reasonable, and the daemon default
|
21
|
+
# Note that the daemon will grow to this size, but does not start out holding this much
|
22
|
+
# memory
|
23
|
+
-m <%= resource.memory_size %>
|
24
|
+
|
25
|
+
# Default connection port is 11211
|
26
|
+
-p <%= resource.listen_port %>
|
27
|
+
|
28
|
+
# Run the daemon as root. The start-memcached will default to running as root if no
|
29
|
+
# -u command is present in this config file
|
30
|
+
-u <%= resource.user %>
|
31
|
+
|
32
|
+
# Specify which IP address to listen on. The default is to listen on all IP addresses
|
33
|
+
# This parameter is one of the only security measures that memcached has, so make sure
|
34
|
+
# it's listening on a firewalled interface.
|
35
|
+
-l <%= resource.bind_address %>
|
36
|
+
|
37
|
+
# Limit the number of simultaneous incoming connections. The daemon default is 1024
|
38
|
+
# -c 1024
|
39
|
+
|
40
|
+
# Lock down all paged memory. Consult with the README and homepage before you do this
|
41
|
+
# -k
|
42
|
+
|
43
|
+
# Return error when memory is exhausted (rather than removing items)
|
44
|
+
# -M
|
45
|
+
|
46
|
+
# Maximize core file limit
|
47
|
+
# -r
|
@@ -0,0 +1,61 @@
|
|
1
|
+
#! /bin/sh
|
2
|
+
### BEGIN INIT INFO
|
3
|
+
# Provides: memcached
|
4
|
+
# Required-Start: $syslog
|
5
|
+
# Required-Stop: $syslog
|
6
|
+
# Should-Start: $local_fs
|
7
|
+
# Should-Stop: $local_fs
|
8
|
+
# Default-Start: 2 3 4 5
|
9
|
+
# Default-Stop: 0 1 6
|
10
|
+
# Short-Description: memcached - Memory caching daemon
|
11
|
+
# Description: memcached - Memory caching daemon
|
12
|
+
### END INIT INFO
|
13
|
+
|
14
|
+
|
15
|
+
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
16
|
+
DAEMON=/usr/bin/memcached
|
17
|
+
DAEMONBOOTSTRAP=/usr/share/memcached/scripts/start-memcached
|
18
|
+
NAME=memcached
|
19
|
+
DESC=memcached
|
20
|
+
PIDFILE=/var/run/$NAME.pid
|
21
|
+
|
22
|
+
test -x $DAEMON || exit 0
|
23
|
+
test -x $DAEMONBOOTSTRAP || exit 0
|
24
|
+
|
25
|
+
set -e
|
26
|
+
|
27
|
+
case "$1" in
|
28
|
+
start)
|
29
|
+
echo -n "Starting $DESC: "
|
30
|
+
start-stop-daemon --start --quiet --exec $DAEMONBOOTSTRAP
|
31
|
+
echo "$NAME."
|
32
|
+
;;
|
33
|
+
stop)
|
34
|
+
echo -n "Stopping $DESC: "
|
35
|
+
start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON
|
36
|
+
echo "$NAME."
|
37
|
+
rm -f $PIDFILE
|
38
|
+
;;
|
39
|
+
|
40
|
+
restart|force-reload)
|
41
|
+
#
|
42
|
+
# If the "reload" option is implemented, move the "force-reload"
|
43
|
+
# option to the "reload" entry above. If not, "force-reload" is
|
44
|
+
# just the same as "restart".
|
45
|
+
#
|
46
|
+
echo -n "Restarting $DESC: "
|
47
|
+
start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
|
48
|
+
rm -f $PIDFILE
|
49
|
+
sleep 1
|
50
|
+
start-stop-daemon --start --quiet --exec $DAEMONBOOTSTRAP
|
51
|
+
echo "$NAME."
|
52
|
+
;;
|
53
|
+
*)
|
54
|
+
N=/etc/init.d/$NAME
|
55
|
+
# echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
|
56
|
+
echo "Usage: $N {start|stop|restart|force-reload}" >&2
|
57
|
+
exit 1
|
58
|
+
;;
|
59
|
+
esac
|
60
|
+
|
61
|
+
exit 0
|
@@ -0,0 +1,73 @@
|
|
1
|
+
class Memcached < Wakame::Service::Resource
|
2
|
+
|
3
|
+
property :listen_port, {:default => 11211 }
|
4
|
+
property :bind_address, {:default => '127.0.0.1'}
|
5
|
+
property :memory_size, {:default => 64}
|
6
|
+
property :user, {:default => 'nobody'}
|
7
|
+
|
8
|
+
def render_config(template)
|
9
|
+
template.cp('init.d/memcached')
|
10
|
+
template.render('conf/memcached.conf')
|
11
|
+
template.chmod("init.d/memcached", 0755)
|
12
|
+
end
|
13
|
+
|
14
|
+
def on_parent_changed(svc, action)
|
15
|
+
action.trigger_action(Wakame::Actions::DeployConfig.new(svc))
|
16
|
+
action.flush_subactions
|
17
|
+
reload(svc, action)
|
18
|
+
end
|
19
|
+
|
20
|
+
def start(svc, action)
|
21
|
+
cond = ConditionalWait.new { |cond|
|
22
|
+
cond.wait_event(Wakame::Event::ServiceOnline) { |event|
|
23
|
+
event.instance_id == svc.id
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
request = action.actor_request(svc.cloud_host.agent_id,
|
28
|
+
'/service_monitor/register',
|
29
|
+
svc.id, :pidfile, '/var/run/memcached.pid').request
|
30
|
+
action.actor_request(svc.cloud_host.agent_id,
|
31
|
+
'/daemon/start', "memcached", 'init.d/memcached'){ |req|
|
32
|
+
req.wait
|
33
|
+
Wakame.log.debug("#{self.class} process started")
|
34
|
+
}
|
35
|
+
|
36
|
+
cond.wait
|
37
|
+
end
|
38
|
+
|
39
|
+
def stop(svc, action)
|
40
|
+
cond = ConditionalWait.new { |cond|
|
41
|
+
cond.wait_event(Wakame::Event::ServiceOffline) { |event|
|
42
|
+
event.instance_id == svc.id
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
action.actor_request(svc.cloud_host.agent_id,
|
47
|
+
'/daemon/stop', 'memcached', 'init.d/memcached'){ |req|
|
48
|
+
req.wait
|
49
|
+
Wakame.log.debug("#{self.class} process stopped")
|
50
|
+
}
|
51
|
+
|
52
|
+
cond.wait
|
53
|
+
|
54
|
+
request = action.actor_request(svc.cloud_host.agent_id,
|
55
|
+
'/service_monitor/unregister', svc.instance_id).request
|
56
|
+
end
|
57
|
+
|
58
|
+
def reload(svc, action)
|
59
|
+
action.actor_request(svc.cloud_host.agent_id,
|
60
|
+
'/daemon/stop', 'memcached', 'init.d/memcached'){ |req|
|
61
|
+
req.wait
|
62
|
+
# Wakame.log.debug("#{self.class} process stopped")
|
63
|
+
}
|
64
|
+
|
65
|
+
action.actor_request(svc.cloud_host.agent_id,
|
66
|
+
'/daemon/start', "memcached", 'init.d/memcached'){ |req|
|
67
|
+
req.wait
|
68
|
+
# Wakame.log.debug("#{self.class} process started")
|
69
|
+
Wakame.log.debug("#{self.class} process reloaded")
|
70
|
+
}
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
@@ -17,9 +17,8 @@
|
|
17
17
|
# escpecially if they contain "#" chars...
|
18
18
|
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
|
19
19
|
[client]
|
20
|
-
port = <%=
|
20
|
+
port = <%= resource.mysqld_port %>
|
21
21
|
socket = /var/run/mysqld/mysqld.sock
|
22
|
-
default-character-set = utf8
|
23
22
|
|
24
23
|
# Here is entries for some specific programs
|
25
24
|
# The following values assume you have at least 32M ram
|
@@ -43,12 +42,11 @@ nice = 0
|
|
43
42
|
user = mysql
|
44
43
|
pid-file = /var/run/mysqld/mysqld.pid
|
45
44
|
socket = /var/run/mysqld/mysqld.sock
|
46
|
-
port = <%=
|
45
|
+
port = <%= resource.mysqld_port %>
|
47
46
|
basedir = /usr
|
48
|
-
datadir = <%=
|
47
|
+
datadir = <%= resource.mysqld_datadir %>
|
49
48
|
tmpdir = /tmp
|
50
49
|
language = /usr/share/mysql/english
|
51
|
-
default-character-set = utf8
|
52
50
|
skip-external-locking
|
53
51
|
#
|
54
52
|
# Instead of skip-networking the default is now to listen only on
|
@@ -87,8 +85,8 @@ long_query_time = 2
|
|
87
85
|
# The following can be used as easy to replay backup logs or for replication.
|
88
86
|
# note: if you are setting up a replication slave, see README.Debian about
|
89
87
|
# other settings you may need to change.
|
90
|
-
server-id =
|
91
|
-
log_bin = <%=
|
88
|
+
server-id = <%= resource.mysqld_server_id %>
|
89
|
+
log_bin = <%= resource.mysqld_log_bin %>
|
92
90
|
#expire_logs_days = 10
|
93
91
|
#max_binlog_size = 100M
|
94
92
|
#binlog_do_db = include_database_name
|