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
@@ -1,16 +1,14 @@
|
|
1
1
|
|
2
2
|
class MySQL_Master < Wakame::Service::Resource
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
property :duplicable, {:default=>false}
|
5
|
+
property :mysqld_server_id, {:default=>1}
|
6
|
+
property :mysqld_port, {:default=>3306}
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
def_attribute :repl_user, 'wakame-repl'
|
13
|
-
def_attribute :repl_pass, 'wakame-slave'
|
8
|
+
property :mysqld_basedir
|
9
|
+
property :ebs_volume
|
10
|
+
property :ebs_device
|
11
|
+
property :ebs_mount_option, {:default=>'noatime'}
|
14
12
|
|
15
13
|
def basedir
|
16
14
|
File.join(Wakame.config.root_path, 'cluster', 'resources', 'mysql_master')
|
@@ -25,20 +23,23 @@ class MySQL_Master < Wakame::Service::Resource
|
|
25
23
|
end
|
26
24
|
|
27
25
|
def render_config(template)
|
28
|
-
template.cp(
|
29
|
-
template.render(
|
26
|
+
template.cp('init.d/mysql')
|
27
|
+
template.render('conf/my.cnf')
|
30
28
|
template.chmod("init.d/mysql", 0755)
|
31
29
|
end
|
32
30
|
|
31
|
+
|
33
32
|
def start(svc, action)
|
33
|
+
# $ echo "GRANT REPLICATION SLAVE, REPLICATION CLIENT, RELOAD ON *.* TO 'wakame-repl'@'%' IDENTIFIED BY 'wakame-slave';" | /usr/bin/mysql -h#{mysql_master_ip} -uroot
|
34
|
+
|
34
35
|
require 'right_aws'
|
35
36
|
ec2 = RightAws::Ec2.new(Wakame.config.aws_access_key, Wakame.config.aws_secret_key)
|
36
37
|
|
37
38
|
res = ec2.describe_volumes([self.ebs_volume])[0]
|
38
39
|
ec2_instance_id = res[:aws_instance_id]
|
39
|
-
if res[:aws_status] == 'in-use' && ec2_instance_id == svc.agent.
|
40
|
+
if res[:aws_status] == 'in-use' && ec2_instance_id == svc.cloud_host.agent.vm_attr[:instance_id]
|
40
41
|
# Nothin to be done
|
41
|
-
elsif res[:aws_status] == 'in-use' && ec2_instance_id != svc.agent.
|
42
|
+
elsif res[:aws_status] == 'in-use' && ec2_instance_id != svc.cloud_host.agent.vm_attr[:instance_id]
|
42
43
|
ec2.detach_volume(self.ebs_volume)
|
43
44
|
cond = ConditionalWait.new { |c|
|
44
45
|
c.poll {
|
@@ -48,7 +49,7 @@ class MySQL_Master < Wakame::Service::Resource
|
|
48
49
|
}
|
49
50
|
cond.wait
|
50
51
|
|
51
|
-
ec2.attach_volume(self.ebs_volume, svc.agent.
|
52
|
+
ec2.attach_volume(self.ebs_volume, svc.cloud_host.agent.vm_attr[:instance_id], self.ebs_device)
|
52
53
|
cond = ConditionalWait.new { |c|
|
53
54
|
c.poll {
|
54
55
|
res1 = ec2.describe_volumes([self.ebs_volume])[0]
|
@@ -58,7 +59,7 @@ class MySQL_Master < Wakame::Service::Resource
|
|
58
59
|
cond.wait
|
59
60
|
|
60
61
|
elsif res[:aws_status] == 'available'
|
61
|
-
ec2.attach_volume(self.ebs_volume, svc.agent.
|
62
|
+
ec2.attach_volume(self.ebs_volume, svc.cloud_host.agent.vm_attr[:instance_id], self.ebs_device)
|
62
63
|
cond = ConditionalWait.new { |c|
|
63
64
|
c.poll {
|
64
65
|
res1 = ec2.describe_volumes([self.ebs_volume])[0]
|
@@ -66,31 +67,27 @@ class MySQL_Master < Wakame::Service::Resource
|
|
66
67
|
}
|
67
68
|
}
|
68
69
|
cond.wait
|
70
|
+
|
69
71
|
end
|
70
72
|
|
71
73
|
cond = ConditionalWait.new { |cond|
|
72
74
|
cond.wait_event(Wakame::Event::ServiceOnline) { |event|
|
73
|
-
event.instance_id == svc.
|
75
|
+
event.instance_id == svc.id
|
74
76
|
}
|
75
77
|
}
|
76
78
|
|
77
|
-
action.actor_request(svc.
|
79
|
+
action.actor_request(svc.cloud_host.agent_id,
|
78
80
|
'/service_monitor/register',
|
79
|
-
svc.
|
80
|
-
:command, "/usr/bin/mysqladmin --defaults-file=#{svc.agent.root_path}/tmp/config/mysql_master/conf/my.cnf ping > /dev/null") { |req|
|
81
|
-
}
|
82
|
-
|
83
|
-
action.actor_request(svc.agent.agent_id, '/system/sync') { |req|
|
84
|
-
req.wait
|
85
|
-
Wakame.log.debug("sync")
|
81
|
+
svc.id,
|
82
|
+
:command, "/usr/bin/mysqladmin --defaults-file=#{svc.cloud_host.agent.root_path}/tmp/config/mysql_master/conf/my.cnf ping > /dev/null") { |req|
|
86
83
|
}
|
87
84
|
|
88
|
-
action.actor_request(svc.
|
85
|
+
action.actor_request(svc.cloud_host.agent_id, '/system/mount', self.ebs_device, self.mysqld_datadir, self.ebs_mount_option) { |req|
|
89
86
|
req.wait
|
90
87
|
Wakame.log.debug("MySQL volume was mounted: #{self.mysqld_datadir}")
|
91
88
|
}
|
92
89
|
|
93
|
-
action.actor_request(svc.
|
90
|
+
action.actor_request(svc.cloud_host.agent_id, '/daemon/start', 'mysql_master', 'init.d/mysql') { |req|
|
94
91
|
req.wait
|
95
92
|
Wakame.log.debug("MySQL process started")
|
96
93
|
}
|
@@ -99,20 +96,24 @@ class MySQL_Master < Wakame::Service::Resource
|
|
99
96
|
end
|
100
97
|
|
101
98
|
def stop(svc, action)
|
102
|
-
cond = ConditionalWait.new { |
|
103
|
-
|
104
|
-
event.instance_id == svc.
|
99
|
+
cond = ConditionalWait.new { |cond|
|
100
|
+
cond.wait_event(Wakame::Event::ServiceOffline) { |event|
|
101
|
+
event.instance_id == svc.id
|
105
102
|
}
|
106
|
-
}
|
107
|
-
|
108
|
-
action.actor_request(svc.
|
103
|
+
}
|
104
|
+
|
105
|
+
action.actor_request(svc.cloud_host.agent_id, '/daemon/stop', 'mysql_master', 'init.d/mysql') { |req| req.wait }
|
106
|
+
action.actor_request(svc.cloud_host.agent_id, '/system/umount', self.mysqld_datadir) { |req|
|
109
107
|
req.wait
|
110
108
|
Wakame.log.debug("MySQL volume unmounted")
|
111
109
|
}
|
110
|
+
|
112
111
|
cond.wait
|
113
112
|
|
114
|
-
|
113
|
+
#TODO: Add detach_volume() AWS call here.
|
114
|
+
|
115
|
+
action.actor_request(svc.cloud_host.agent_id,
|
115
116
|
'/service_monitor/unregister',
|
116
|
-
svc.
|
117
|
+
svc.id).request
|
117
118
|
end
|
118
119
|
end
|
@@ -17,7 +17,7 @@
|
|
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-slave.sock
|
22
22
|
default-character-set = utf8
|
23
23
|
|
@@ -43,9 +43,9 @@ nice = 0
|
|
43
43
|
user = mysql
|
44
44
|
pid-file = /var/run/mysqld/mysqld-slave.pid
|
45
45
|
socket = /var/run/mysqld/mysqld-slave.sock
|
46
|
-
port = <%=
|
46
|
+
port = <%= resource.mysqld_port %>
|
47
47
|
basedir = /usr
|
48
|
-
datadir = <%=
|
48
|
+
datadir = <%= resource.mysqld_datadir %>
|
49
49
|
tmpdir = /tmp
|
50
50
|
language = /usr/share/mysql/english
|
51
51
|
default-character-set = utf8
|
@@ -90,11 +90,11 @@ long_query_time = 2
|
|
90
90
|
|
91
91
|
<%-
|
92
92
|
require 'ipaddr'
|
93
|
-
mysqld_server_id = IPAddr.new(
|
93
|
+
mysqld_server_id = IPAddr.new(cloud_host.agent_ip).to_i
|
94
94
|
-%>
|
95
95
|
server-id = <%= mysqld_server_id %>
|
96
|
-
relay-log = <%=
|
97
|
-
relay-log-index = <%=
|
96
|
+
relay-log = <%= resource.mysqld_datadir %>/mysqld-relay-bin
|
97
|
+
relay-log-index = <%= resource.mysqld_datadir %>/mysqld-relay-bin
|
98
98
|
read_only
|
99
99
|
|
100
100
|
#expire_logs_days = 10
|
@@ -1,14 +1,11 @@
|
|
1
1
|
|
2
2
|
class MySQL_Slave < Wakame::Service::Resource
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
property :mysqld_basedir, {:default=>'/home/wakame/mysql'}
|
5
|
+
property :mysqld_port, {:default=>3307}
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
def_attribute :ebs_device, '/dev/sdn'
|
11
|
-
def_attribute :ebs_mount_option, 'noatime'
|
7
|
+
property :ebs_device
|
8
|
+
property :ebs_mount_option, {:default=>'noatime'}
|
12
9
|
|
13
10
|
def basedir
|
14
11
|
File.join(Wakame.config.root_path, 'cluster', 'resources', 'mysql_slave')
|
@@ -23,22 +20,22 @@ class MySQL_Slave < Wakame::Service::Resource
|
|
23
20
|
end
|
24
21
|
|
25
22
|
def render_config(template)
|
26
|
-
template.cp(
|
27
|
-
template.render(
|
28
|
-
template.chmod(
|
23
|
+
template.cp('init.d/mysql-slave')
|
24
|
+
template.render('conf/my.cnf')
|
25
|
+
template.chmod('init.d/mysql-slave', 0755)
|
29
26
|
end
|
30
27
|
|
31
28
|
def start(svc, action)
|
32
29
|
cond = ConditionalWait.new { |cond|
|
33
30
|
cond.wait_event(Wakame::Event::ServiceOnline) { |event|
|
34
|
-
event.instance_id == svc.
|
31
|
+
event.instance_id == svc.id
|
35
32
|
}
|
36
33
|
}
|
37
34
|
|
38
|
-
action.actor_request(svc.
|
35
|
+
action.actor_request(svc.cloud_host.agent_id,
|
39
36
|
'/service_monitor/register',
|
40
|
-
svc.
|
41
|
-
:command, "/usr/bin/mysqladmin --defaults-file=#{svc.
|
37
|
+
svc.id,
|
38
|
+
:command, "/usr/bin/mysqladmin --defaults-file=#{svc.cloud_host.root_path}/tmp/config/mysql_slave/conf/my.cnf ping > /dev/null") { |req|
|
42
39
|
}
|
43
40
|
|
44
41
|
opt_map = {
|
@@ -55,22 +52,22 @@ class MySQL_Slave < Wakame::Service::Resource
|
|
55
52
|
opt_map[:repl_pass] = mysql_master.resource.repl_pass
|
56
53
|
}
|
57
54
|
|
58
|
-
action.actor_request(svc.
|
55
|
+
action.actor_request(svc.cloud_host.agent_id, '/mysql/take_master_snapshot', opt_map) { |req|
|
59
56
|
req.wait
|
60
57
|
Wakame.log.debug("take-master-snapshot!!")
|
61
58
|
}
|
62
59
|
|
63
|
-
action.actor_request(svc.
|
60
|
+
action.actor_request(svc.cloud_host.agent_id, '/system/sync') { |req|
|
64
61
|
req.wait
|
65
62
|
Wakame.log.debug("sync")
|
66
63
|
}
|
67
64
|
|
68
|
-
action.actor_request(svc.
|
65
|
+
action.actor_request(svc.cloud_host.agent_id, '/system/mount', self.ebs_device, self.mysqld_datadir, self.ebs_mount_option) { |req|
|
69
66
|
req.wait
|
70
67
|
Wakame.log.debug("MySQL volume was mounted: #{self.mysqld_datadir}")
|
71
68
|
}
|
72
69
|
|
73
|
-
action.actor_request(svc.
|
70
|
+
action.actor_request(svc.cloud_host.agent_id, '/daemon/start', 'mysql_slave', 'init.d/mysql-slave') { |req|
|
74
71
|
req.wait
|
75
72
|
Wakame.log.debug("MySQL process started")
|
76
73
|
}
|
@@ -80,11 +77,11 @@ class MySQL_Slave < Wakame::Service::Resource
|
|
80
77
|
def stop(svc, action)
|
81
78
|
cond = ConditionalWait.new { |c|
|
82
79
|
c.wait_event(Wakame::Event::ServiceOffline) { |event|
|
83
|
-
event.instance_id == svc.
|
80
|
+
event.instance_id == svc.id
|
84
81
|
}
|
85
82
|
}
|
86
|
-
action.actor_request(svc.
|
87
|
-
action.actor_request(svc.
|
83
|
+
action.actor_request(svc.cloud_host.agent_id, '/daemon/stop', 'mysql_slave', 'init.d/mysql-slave') { |req| req.wait }
|
84
|
+
action.actor_request(svc.cloud_host.agent_id, '/system/umount', self.mysqld_datadir) { |req|
|
88
85
|
req.wait
|
89
86
|
Wakame.log.debug("MySQL volume unmounted")
|
90
87
|
}
|
@@ -93,7 +90,7 @@ class MySQL_Slave < Wakame::Service::Resource
|
|
93
90
|
require 'right_aws'
|
94
91
|
ec2 = RightAws::Ec2.new(Wakame.config.aws_access_key, Wakame.config.aws_secret_key)
|
95
92
|
ec2.describe_volumes.each do |volume|
|
96
|
-
next unless volume[:aws_instance_id] == svc.
|
93
|
+
next unless volume[:aws_instance_id] == svc.cloud_host.agent_id && volume[:aws_device] == self.ebs_device
|
97
94
|
|
98
95
|
@ebs_volume = volume[:aws_id]
|
99
96
|
|
@@ -115,9 +112,9 @@ class MySQL_Slave < Wakame::Service::Resource
|
|
115
112
|
end
|
116
113
|
|
117
114
|
# unregister
|
118
|
-
action.actor_request(svc.
|
115
|
+
action.actor_request(svc.cloud_host.agent_id,
|
119
116
|
'/service_monitor/unregister',
|
120
|
-
svc.
|
117
|
+
svc.id).request
|
121
118
|
|
122
119
|
end
|
123
120
|
end
|
@@ -35,17 +35,28 @@ http {
|
|
35
35
|
gzip on;
|
36
36
|
|
37
37
|
|
38
|
-
upstream
|
39
|
-
|
38
|
+
upstream app-group {
|
39
|
+
server 111.111.111.111:8080 down;
|
40
|
+
<%- cluster.each_instance(HttpApplicationServer) { |n|
|
40
41
|
next if n.status != STATUS_ONLINE
|
41
42
|
-%>
|
42
|
-
server <%= n.
|
43
|
+
server <%= n.cloud_host.agent_ip %>:<%= n.resource.listen_port %>;
|
43
44
|
<%- } -%>
|
44
45
|
}
|
46
|
+
<%# if cluster.instance_count(HttpAssetServer) > 0 -%>
|
47
|
+
upstream asset-group {
|
48
|
+
server 111.111.111.111:8080 down;
|
49
|
+
<%- cluster.each_instance(HttpAssetServer) { |n|
|
50
|
+
next if n.status != STATUS_ONLINE
|
51
|
+
-%>
|
52
|
+
server <%= n.cloud_host.agent_ip %>:<%= n.resource.listen_port %>;
|
53
|
+
<%- } -%>
|
54
|
+
}
|
55
|
+
<%# end -%>
|
45
56
|
|
46
57
|
|
47
|
-
server {
|
48
|
-
listen
|
58
|
+
server {
|
59
|
+
listen <%= resource.listen_port %>;
|
49
60
|
server_name localhost;
|
50
61
|
|
51
62
|
access_log /var/log/nginx/localhost.access.log combined;
|
@@ -97,30 +108,10 @@ server {
|
|
97
108
|
#location ~ /\.ht {
|
98
109
|
#deny all;
|
99
110
|
#}
|
100
|
-
}
|
101
|
-
|
102
|
-
<%- service_cluster.virtual_hosts.each { |vh| -%>
|
103
|
-
server {
|
104
|
-
listen 80;
|
105
|
-
server_name <%= vh.server_name %>;
|
106
|
-
access_log /var/log/nginx/<%= vh.server_name %>-access.log combined buffer=32k;
|
107
|
-
error_log /var/log/nginx/<%= vh.server_name %>-error.log info;
|
108
|
-
root /var/www;
|
109
|
-
|
110
|
-
location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico|htm|html)$ {
|
111
|
-
expires 30d;
|
112
|
-
}
|
113
|
-
|
114
|
-
location / {
|
115
|
-
proxy_pass http://appcluster;
|
116
|
-
index index.html index.htm;
|
117
111
|
}
|
118
112
|
|
119
|
-
|
120
|
-
deny all;
|
121
|
-
}
|
113
|
+
include vh/*.conf;
|
122
114
|
}
|
123
|
-
<%- } -%>
|
124
115
|
|
125
116
|
# another virtual host using mix of IP-, name-, and port-based configuration
|
126
117
|
#
|
@@ -161,6 +152,5 @@ server {
|
|
161
152
|
|
162
153
|
#include /etc/nginx/conf.d/*.conf;
|
163
154
|
#include /etc/nginx/sites-enabled/*;
|
164
|
-
}
|
165
155
|
|
166
156
|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
server {
|
2
|
+
listen <%= resource.listen_port %>;
|
3
|
+
server_name aaa.test;
|
4
|
+
access_log /var/log/nginx/aaa.test-access.log combined buffer=32k;
|
5
|
+
error_log /var/log/nginx/aaa.test-error.log info;
|
6
|
+
root /var/www;
|
7
|
+
|
8
|
+
location ~* ^.+\.(jpg|jpe?g|gif|css|png|js|ico|htm?l|swf|flv)$ {
|
9
|
+
expires 30d;
|
10
|
+
#proxy_pass http://asset-group;
|
11
|
+
proxy_pass http://your-bucket.s3.amazonaws.com;
|
12
|
+
#rewrite ^(.*)$ http://your-bucket.s3.cloudfront.net$1 permanent;
|
13
|
+
}
|
14
|
+
|
15
|
+
location ~* ^/(image?s|img?s|javascript?s|js|stylesheet?s|css)/.+ {
|
16
|
+
expires 30d;
|
17
|
+
#proxy_pass http://asset-group;
|
18
|
+
proxy_pass http://your-bucket.s3.amazonaws.com;
|
19
|
+
#rewrite ^(.*)$ http://your-bucket.s3.cloudfront.net$1 permanent;
|
20
|
+
}
|
21
|
+
|
22
|
+
location / {
|
23
|
+
proxy_pass http://app-group;
|
24
|
+
index index.html index.htm;
|
25
|
+
}
|
26
|
+
|
27
|
+
location ~ /\.ht {
|
28
|
+
deny all;
|
29
|
+
}
|
30
|
+
}
|
@@ -1,33 +1,33 @@
|
|
1
|
-
|
2
|
-
require 'wakame/rule'
|
3
|
-
|
4
1
|
class Nginx < Wakame::Service::Resource
|
5
|
-
include
|
2
|
+
include HttpServer
|
6
3
|
|
7
|
-
|
8
|
-
|
4
|
+
property :listen_port, {:default=>80}
|
5
|
+
property :listen_port_https, {:default=>443}
|
9
6
|
|
10
7
|
def render_config(template)
|
11
|
-
template.
|
12
|
-
|
8
|
+
template.glob_basedir(%w(conf/nginx.conf conf/vh/*.conf)) { |d|
|
9
|
+
template.render(d)
|
10
|
+
}
|
11
|
+
template.cp('init.d/nginx')
|
13
12
|
template.chmod("init.d/nginx", 0755)
|
14
13
|
end
|
15
14
|
|
16
15
|
def on_parent_changed(svc, action)
|
17
|
-
Wakame::
|
16
|
+
action.trigger_action(Wakame::Actions::DeployConfig.new(svc))
|
17
|
+
action.flush_subactions
|
18
18
|
reload(svc, action)
|
19
19
|
end
|
20
20
|
|
21
21
|
def start(svc, action)
|
22
22
|
cond = ConditionalWait.new { |cond|
|
23
23
|
cond.wait_event(Wakame::Event::ServiceOnline) { |event|
|
24
|
-
event.instance_id == svc.
|
24
|
+
event.instance_id == svc.id
|
25
25
|
}
|
26
26
|
}
|
27
27
|
|
28
|
-
request = action.actor_request(svc.
|
29
|
-
'/service_monitor/register', svc.
|
30
|
-
action.actor_request(svc.
|
28
|
+
request = action.actor_request(svc.cloud_host.agent_id,
|
29
|
+
'/service_monitor/register', svc.id, :pidfile, '/var/run/nginx.pid').request
|
30
|
+
action.actor_request(svc.cloud_host.agent_id,
|
31
31
|
'/daemon/start', "nginx", 'init.d/nginx'){ |req|
|
32
32
|
req.wait
|
33
33
|
Wakame.log.debug("#{self.class} process started")
|
@@ -39,11 +39,11 @@ class Nginx < Wakame::Service::Resource
|
|
39
39
|
def stop(svc, action)
|
40
40
|
cond = ConditionalWait.new { |cond|
|
41
41
|
cond.wait_event(Wakame::Event::ServiceOffline) { |event|
|
42
|
-
event.instance_id == svc.
|
42
|
+
event.instance_id == svc.id
|
43
43
|
}
|
44
44
|
}
|
45
45
|
|
46
|
-
action.actor_request(svc.
|
46
|
+
action.actor_request(svc.cloud_host.agent_id,
|
47
47
|
'/daemon/stop', 'nginx', 'init.d/nginx'){ |req|
|
48
48
|
req.wait
|
49
49
|
Wakame.log.debug("#{self.class} process stopped")
|
@@ -51,12 +51,12 @@ class Nginx < Wakame::Service::Resource
|
|
51
51
|
|
52
52
|
cond.wait
|
53
53
|
|
54
|
-
request = action.actor_request(svc.
|
55
|
-
'/service_monitor/unregister', svc.
|
54
|
+
request = action.actor_request(svc.cloud_host.agent_id,
|
55
|
+
'/service_monitor/unregister', svc.id ).request
|
56
56
|
end
|
57
57
|
|
58
58
|
def reload(svc, action)
|
59
|
-
action.actor_request(svc.
|
59
|
+
action.actor_request(svc.cloud_host.agent_id,
|
60
60
|
'/daemon/reload', "nginx", 'init.d/nginx'){ |req|
|
61
61
|
req.wait
|
62
62
|
Wakame.log.debug("#{self.class} process reloaded")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wakame
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- axsh co.,Ltd.
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-
|
13
|
+
date: 2009-09-18 00:00:00 +09:00
|
14
14
|
default_executable: wakame
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -23,16 +23,6 @@ dependencies:
|
|
23
23
|
- !ruby/object:Gem::Version
|
24
24
|
version: 0.6.0
|
25
25
|
version:
|
26
|
-
- !ruby/object:Gem::Dependency
|
27
|
-
name: amazon-ec2
|
28
|
-
type: :runtime
|
29
|
-
version_requirement:
|
30
|
-
version_requirements: !ruby/object:Gem::Requirement
|
31
|
-
requirements:
|
32
|
-
- - ">="
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version: 0.3.6
|
35
|
-
version:
|
36
26
|
- !ruby/object:Gem::Dependency
|
37
27
|
name: right_aws
|
38
28
|
type: :runtime
|
@@ -143,6 +133,16 @@ dependencies:
|
|
143
133
|
- !ruby/object:Gem::Version
|
144
134
|
version: 1.1.7
|
145
135
|
version:
|
136
|
+
- !ruby/object:Gem::Dependency
|
137
|
+
name: sequel
|
138
|
+
type: :runtime
|
139
|
+
version_requirement:
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: 3.2.0
|
145
|
+
version:
|
146
146
|
description: ""
|
147
147
|
email:
|
148
148
|
- m-fujiwara@axsh.net
|
@@ -162,6 +162,9 @@ files:
|
|
162
162
|
- app_generators/wakame/templates/bin/wakame-agent
|
163
163
|
- app_generators/wakame/templates/bin/wakame-master
|
164
164
|
- app_generators/wakame/templates/bin/wakameadm
|
165
|
+
- app_generators/wakame/templates/cluster/resources/markers/http_application_server.rb
|
166
|
+
- app_generators/wakame/templates/cluster/resources/markers/http_asset_server.rb
|
167
|
+
- app_generators/wakame/templates/cluster/resources/markers/http_server.rb
|
165
168
|
- app_generators/wakame/templates/config/boot.rb
|
166
169
|
- app_generators/wakame/templates/config/cluster.rb
|
167
170
|
- app_generators/wakame/templates/config/environments/common.rb
|
@@ -177,11 +180,16 @@ files:
|
|
177
180
|
- lib/ext/uri.rb
|
178
181
|
- lib/wakame.rb
|
179
182
|
- lib/wakame/action.rb
|
183
|
+
- lib/wakame/action_manager.rb
|
184
|
+
- lib/wakame/actions/deploy_config.rb
|
180
185
|
- lib/wakame/actions/destroy_instances.rb
|
181
186
|
- lib/wakame/actions/launch_cluster.rb
|
182
187
|
- lib/wakame/actions/launch_vm.rb
|
183
188
|
- lib/wakame/actions/migrate_service.rb
|
184
|
-
- lib/wakame/actions/
|
189
|
+
- lib/wakame/actions/notify_child_changed.rb
|
190
|
+
- lib/wakame/actions/notify_parent_changed.rb
|
191
|
+
- lib/wakame/actions/propagate_resource.rb
|
192
|
+
- lib/wakame/actions/propagate_service.rb
|
185
193
|
- lib/wakame/actions/reload_service.rb
|
186
194
|
- lib/wakame/actions/scaleout_when_high_load.rb
|
187
195
|
- lib/wakame/actions/shutdown_cluster.rb
|
@@ -201,13 +209,16 @@ files:
|
|
201
209
|
- lib/wakame/command/actor.rb
|
202
210
|
- lib/wakame/command/agent_status.rb
|
203
211
|
- lib/wakame/command/clone_service.rb
|
212
|
+
- lib/wakame/command/import_cluster_config.rb
|
204
213
|
- lib/wakame/command/launch_cluster.rb
|
205
214
|
- lib/wakame/command/launch_vm.rb
|
206
215
|
- lib/wakame/command/migrate_service.rb
|
216
|
+
- lib/wakame/command/propagate_resource.rb
|
207
217
|
- lib/wakame/command/propagate_service.rb
|
208
218
|
- lib/wakame/command/reload_service.rb
|
209
219
|
- lib/wakame/command/shutdown_cluster.rb
|
210
220
|
- lib/wakame/command/shutdown_vm.rb
|
221
|
+
- lib/wakame/command/start_service.rb
|
211
222
|
- lib/wakame/command/status.rb
|
212
223
|
- lib/wakame/command/stop_service.rb
|
213
224
|
- lib/wakame/command_queue.rb
|
@@ -219,26 +230,23 @@ files:
|
|
219
230
|
- lib/wakame/initializer.rb
|
220
231
|
- lib/wakame/instance_counter.rb
|
221
232
|
- lib/wakame/logger.rb
|
222
|
-
- lib/wakame/manager/commands.rb
|
223
233
|
- lib/wakame/master.rb
|
224
234
|
- lib/wakame/monitor.rb
|
225
235
|
- lib/wakame/monitor/agent.rb
|
226
236
|
- lib/wakame/monitor/service.rb
|
227
237
|
- lib/wakame/packets.rb
|
228
238
|
- lib/wakame/queue_declare.rb
|
229
|
-
- lib/wakame/rule.rb
|
230
|
-
- lib/wakame/rule_engine.rb
|
231
239
|
- lib/wakame/runner/administrator_command.rb
|
232
240
|
- lib/wakame/runner/agent.rb
|
233
241
|
- lib/wakame/runner/master.rb
|
234
242
|
- lib/wakame/scheduler.rb
|
235
243
|
- lib/wakame/service.rb
|
244
|
+
- lib/wakame/status_db.rb
|
236
245
|
- lib/wakame/template.rb
|
237
246
|
- lib/wakame/trigger.rb
|
238
247
|
- lib/wakame/triggers/instance_count_update.rb
|
239
248
|
- lib/wakame/triggers/load_history.rb
|
240
249
|
- lib/wakame/triggers/maintain_ssh_known_hosts.rb
|
241
|
-
- lib/wakame/triggers/process_command.rb
|
242
250
|
- lib/wakame/triggers/shutdown_unused_vm.rb
|
243
251
|
- lib/wakame/util.rb
|
244
252
|
- lib/wakame/vm_manipulator.rb
|
@@ -246,15 +254,16 @@ files:
|
|
246
254
|
- tests/cluster.json
|
247
255
|
- tests/setup_agent.rb
|
248
256
|
- tests/setup_master.rb
|
257
|
+
- tests/test_action_manager.rb
|
249
258
|
- tests/test_actor.rb
|
250
259
|
- tests/test_agent.rb
|
251
260
|
- tests/test_amqp_client.rb
|
252
261
|
- tests/test_graph.rb
|
253
262
|
- tests/test_master.rb
|
254
263
|
- tests/test_monitor.rb
|
255
|
-
- tests/test_rule_engine.rb
|
256
264
|
- tests/test_scheduler.rb
|
257
265
|
- tests/test_service.rb
|
266
|
+
- tests/test_status_db.rb
|
258
267
|
- tests/test_template.rb
|
259
268
|
- tests/test_uri_amqp.rb
|
260
269
|
- tests/test_util.rb
|
@@ -262,23 +271,26 @@ files:
|
|
262
271
|
- wakame_generators/resource/templates/apache_app/apache_app.rb
|
263
272
|
- wakame_generators/resource/templates/apache_app/conf/apache2.conf
|
264
273
|
- wakame_generators/resource/templates/apache_app/conf/envvars-app
|
265
|
-
- wakame_generators/resource/templates/apache_app/conf/sites-app.conf
|
266
274
|
- wakame_generators/resource/templates/apache_app/conf/system-app.conf
|
275
|
+
- wakame_generators/resource/templates/apache_app/conf/vh/aaa.test.conf
|
267
276
|
- wakame_generators/resource/templates/apache_app/init.d/apache2-app
|
268
277
|
- wakame_generators/resource/templates/apache_lb/apache_lb.rb
|
269
278
|
- wakame_generators/resource/templates/apache_lb/conf/apache2.conf
|
270
279
|
- wakame_generators/resource/templates/apache_lb/conf/envvars-lb
|
271
|
-
- wakame_generators/resource/templates/apache_lb/conf/sites-lb.conf
|
272
280
|
- wakame_generators/resource/templates/apache_lb/conf/system-lb.conf
|
281
|
+
- wakame_generators/resource/templates/apache_lb/conf/vh/aaa.test.conf
|
273
282
|
- wakame_generators/resource/templates/apache_lb/init.d/apache2-lb
|
274
283
|
- wakame_generators/resource/templates/apache_www/apache_www.rb
|
275
284
|
- wakame_generators/resource/templates/apache_www/conf/apache2.conf
|
276
285
|
- wakame_generators/resource/templates/apache_www/conf/envvars-www
|
277
|
-
- wakame_generators/resource/templates/apache_www/conf/sites-www.conf
|
278
286
|
- wakame_generators/resource/templates/apache_www/conf/system-www.conf
|
287
|
+
- wakame_generators/resource/templates/apache_www/conf/vh/aaa.test.conf
|
279
288
|
- wakame_generators/resource/templates/apache_www/init.d/apache2-www
|
280
289
|
- wakame_generators/resource/templates/ec2_elastic_ip/ec2_elastic_ip.rb
|
281
290
|
- wakame_generators/resource/templates/ec2_elb/ec2_elb.rb
|
291
|
+
- wakame_generators/resource/templates/memcached/conf/memcached.conf
|
292
|
+
- wakame_generators/resource/templates/memcached/init.d/memcached
|
293
|
+
- wakame_generators/resource/templates/memcached/memcached.rb
|
282
294
|
- wakame_generators/resource/templates/mysql_master/conf/my.cnf
|
283
295
|
- wakame_generators/resource/templates/mysql_master/init.d/mysql
|
284
296
|
- wakame_generators/resource/templates/mysql_master/mysql_master.rb
|
@@ -286,6 +298,7 @@ files:
|
|
286
298
|
- wakame_generators/resource/templates/mysql_slave/init.d/mysql-slave
|
287
299
|
- wakame_generators/resource/templates/mysql_slave/mysql_slave.rb
|
288
300
|
- wakame_generators/resource/templates/nginx/conf/nginx.conf
|
301
|
+
- wakame_generators/resource/templates/nginx/conf/vh/aaa.test.conf
|
289
302
|
- wakame_generators/resource/templates/nginx/init.d/nginx
|
290
303
|
- wakame_generators/resource/templates/nginx/nginx.rb
|
291
304
|
has_rdoc: true
|