wakame 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +18 -0
- data/README.rdoc +2 -4
- data/Rakefile +4 -1
- data/VERSION +1 -1
- data/app_generators/wakame/templates/config/cluster.rb +36 -0
- data/app_generators/wakame/wakame_generator.rb +1 -0
- data/lib/wakame/action.rb +19 -34
- data/lib/wakame/actions/launch_cluster.rb +6 -3
- data/lib/wakame/actions/launch_vm.rb +57 -0
- data/lib/wakame/actions/migrate_service.rb +6 -25
- data/lib/wakame/actions/propagate_instances.rb +16 -41
- data/lib/wakame/actions/reload_service.rb +2 -2
- data/lib/wakame/actions/shutdown_cluster.rb +4 -0
- data/lib/wakame/actions/start_service.rb +30 -9
- data/lib/wakame/actions/stop_service.rb +1 -4
- data/lib/wakame/actions/util.rb +0 -24
- data/lib/wakame/actor/mysql.rb +106 -0
- data/lib/wakame/actor/service_monitor.rb +10 -0
- data/lib/wakame/actor/system.rb +19 -9
- data/lib/wakame/actor.rb +1 -1
- data/lib/wakame/agent.rb +23 -17
- data/lib/wakame/command/action_status.rb +7 -38
- data/lib/wakame/command/agent_status.rb +18 -0
- data/lib/wakame/command/launch_cluster.rb +0 -4
- data/lib/wakame/command/launch_vm.rb +11 -0
- data/lib/wakame/command/migrate_service.rb +12 -9
- data/lib/wakame/command/propagate_service.rb +15 -7
- data/lib/wakame/command/reload_service.rb +21 -0
- data/lib/wakame/command/shutdown_cluster.rb +0 -5
- data/lib/wakame/command/shutdown_vm.rb +20 -0
- data/lib/wakame/command/status.rb +6 -66
- data/lib/wakame/command/stop_service.rb +31 -0
- data/lib/wakame/command.rb +3 -0
- data/lib/wakame/command_queue.rb +76 -5
- data/lib/wakame/configuration.rb +6 -1
- data/lib/wakame/event.rb +6 -5
- data/lib/wakame/event_dispatcher.rb +5 -3
- data/lib/wakame/initializer.rb +1 -1
- data/lib/wakame/master.rb +14 -10
- data/lib/wakame/monitor/agent.rb +1 -6
- data/lib/wakame/monitor/service.rb +13 -1
- data/lib/wakame/packets.rb +51 -13
- data/lib/wakame/rule_engine.rb +7 -18
- data/lib/wakame/runner/administrator_command.rb +517 -46
- data/lib/wakame/service.rb +104 -173
- data/lib/wakame/trigger.rb +1 -10
- data/lib/wakame/triggers/process_command.rb +9 -2
- data/lib/wakame/util.rb +21 -21
- data/lib/wakame/vm_manipulator.rb +1 -0
- data/tests/test_service.rb +30 -6
- data/wakame_generators/resource/templates/ec2_elb/ec2_elb.rb +80 -0
- data/wakame_generators/resource/templates/mysql_master/conf/my.cnf +3 -1
- data/wakame_generators/resource/templates/mysql_master/init.d/mysql +3 -3
- data/wakame_generators/resource/templates/mysql_master/mysql_master.rb +11 -12
- data/{app_generators/wakame/templates/cluster/resources/mysql_master → wakame_generators/resource/templates/mysql_slave}/conf/my.cnf +19 -9
- data/{app_generators/wakame/templates/cluster/resources/mysql_master/init.d/mysql → wakame_generators/resource/templates/mysql_slave/init.d/mysql-slave} +4 -4
- data/wakame_generators/resource/templates/mysql_slave/mysql_slave.rb +123 -0
- data/wakame_generators/resource/templates/nginx/conf/nginx.conf +166 -0
- data/wakame_generators/resource/templates/nginx/init.d/nginx +70 -0
- data/{app_generators/wakame/templates/cluster/resources/apache_lb/apache_lb.rb → wakame_generators/resource/templates/nginx/nginx.rb} +28 -17
- metadata +46 -27
- data/app_generators/wakame/templates/cluster/resources/apache_app/apache_app.rb +0 -54
- data/app_generators/wakame/templates/cluster/resources/apache_app/conf/apache2.conf +0 -46
- data/app_generators/wakame/templates/cluster/resources/apache_app/conf/envvars-app +0 -7
- data/app_generators/wakame/templates/cluster/resources/apache_app/conf/sites-app.conf +0 -23
- data/app_generators/wakame/templates/cluster/resources/apache_app/conf/system-app.conf +0 -67
- data/app_generators/wakame/templates/cluster/resources/apache_app/init.d/apache2-app +0 -192
- data/app_generators/wakame/templates/cluster/resources/apache_lb/conf/apache2.conf +0 -46
- data/app_generators/wakame/templates/cluster/resources/apache_lb/conf/envvars-lb +0 -6
- data/app_generators/wakame/templates/cluster/resources/apache_lb/conf/sites-lb.conf +0 -54
- data/app_generators/wakame/templates/cluster/resources/apache_lb/conf/system-lb.conf +0 -75
- data/app_generators/wakame/templates/cluster/resources/apache_lb/init.d/apache2-lb +0 -192
- data/app_generators/wakame/templates/cluster/resources/apache_www/apache_www.rb +0 -50
- data/app_generators/wakame/templates/cluster/resources/apache_www/conf/apache2.conf +0 -47
- data/app_generators/wakame/templates/cluster/resources/apache_www/conf/envvars-www +0 -7
- data/app_generators/wakame/templates/cluster/resources/apache_www/conf/sites-www.conf +0 -23
- data/app_generators/wakame/templates/cluster/resources/apache_www/conf/system-www.conf +0 -63
- data/app_generators/wakame/templates/cluster/resources/apache_www/init.d/apache2-www +0 -192
- data/app_generators/wakame/templates/cluster/resources/ec2_elastic_ip/ec2_elastic_ip.rb +0 -39
- data/app_generators/wakame/templates/cluster/resources/mysql_master/mysql_master.rb +0 -174
- data/tests/conf/a +0 -1
- data/tests/conf/b +0 -1
- data/tests/conf/c +0 -1
@@ -18,14 +18,15 @@
|
|
18
18
|
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
|
19
19
|
[client]
|
20
20
|
port = <%= property.mysqld_port %>
|
21
|
-
socket = /var/run/mysqld/mysqld.sock
|
21
|
+
socket = /var/run/mysqld/mysqld-slave.sock
|
22
|
+
default-character-set = utf8
|
22
23
|
|
23
24
|
# Here is entries for some specific programs
|
24
25
|
# The following values assume you have at least 32M ram
|
25
26
|
|
26
27
|
# This was formally known as [safe_mysqld]. Both versions are currently parsed.
|
27
28
|
[mysqld_safe]
|
28
|
-
socket = /var/run/mysqld/mysqld.sock
|
29
|
+
socket = /var/run/mysqld/mysqld-slave.sock
|
29
30
|
nice = 0
|
30
31
|
|
31
32
|
[mysqld]
|
@@ -40,13 +41,14 @@ nice = 0
|
|
40
41
|
#
|
41
42
|
|
42
43
|
user = mysql
|
43
|
-
pid-file = /var/run/mysqld/mysqld.pid
|
44
|
-
socket = /var/run/mysqld/mysqld.sock
|
44
|
+
pid-file = /var/run/mysqld/mysqld-slave.pid
|
45
|
+
socket = /var/run/mysqld/mysqld-slave.sock
|
45
46
|
port = <%= property.mysqld_port %>
|
46
47
|
basedir = /usr
|
47
48
|
datadir = <%= property.mysqld_datadir %>
|
48
49
|
tmpdir = /tmp
|
49
50
|
language = /usr/share/mysql/english
|
51
|
+
default-character-set = utf8
|
50
52
|
skip-external-locking
|
51
53
|
#
|
52
54
|
# Instead of skip-networking the default is now to listen only on
|
@@ -72,21 +74,29 @@ query_cache_size = 16M
|
|
72
74
|
#
|
73
75
|
# Both location gets rotated by the cronjob.
|
74
76
|
# Be aware that this log type is a performance killer.
|
75
|
-
log = /var/log/mysql/mysql.log
|
76
|
-
log_error = /var/log/mysql/mysql-error.log
|
77
|
+
log = /var/log/mysql/mysql-slave.log
|
78
|
+
log_error = /var/log/mysql/mysql-slave-error.log
|
77
79
|
#
|
78
80
|
# Error logging goes to syslog. This is a Debian improvement :)
|
79
81
|
#
|
80
82
|
# Here you can see queries with especially long duration
|
81
|
-
log_slow_queries = /var/log/mysql/mysql-slow.log
|
83
|
+
log_slow_queries = /var/log/mysql/mysql-slave-slow.log
|
82
84
|
long_query_time = 2
|
83
85
|
#log-queries-not-using-indexes
|
84
86
|
#
|
85
87
|
# The following can be used as easy to replay backup logs or for replication.
|
86
88
|
# note: if you are setting up a replication slave, see README.Debian about
|
87
89
|
# other settings you may need to change.
|
88
|
-
|
89
|
-
|
90
|
+
|
91
|
+
<%-
|
92
|
+
require 'ipaddr'
|
93
|
+
mysqld_server_id = IPAddr.new(agent.agent_ip).to_i
|
94
|
+
-%>
|
95
|
+
server-id = <%= mysqld_server_id %>
|
96
|
+
relay-log = <%= property.mysqld_datadir %>/mysqld-relay-bin
|
97
|
+
relay-log-index = <%= property.mysqld_datadir %>/mysqld-relay-bin
|
98
|
+
read_only
|
99
|
+
|
90
100
|
#expire_logs_days = 10
|
91
101
|
#max_binlog_size = 100M
|
92
102
|
#binlog_do_db = include_database_name
|
@@ -25,7 +25,7 @@ test -x /usr/sbin/mysqld || exit 0
|
|
25
25
|
. /lib/lsb/init-functions
|
26
26
|
|
27
27
|
SELF=$(cd $(dirname $0); pwd -P)/$(basename $0)
|
28
|
-
CONF=$WAKAME_ROOT/tmp/config/
|
28
|
+
CONF=$WAKAME_ROOT/tmp/config/mysql_slave/conf/my.cnf
|
29
29
|
MYADMIN="/usr/bin/mysqladmin --defaults-file=$CONF"
|
30
30
|
|
31
31
|
# priority can be overriden and "-s" adds output to stderr
|
@@ -44,7 +44,7 @@ export HOME=/etc/mysql/
|
|
44
44
|
#
|
45
45
|
# Usage: void mysqld_get_param option
|
46
46
|
mysqld_get_param() {
|
47
|
-
/usr/sbin/mysqld --print-defaults \
|
47
|
+
/usr/sbin/mysqld --defaults-file=$CONF --print-defaults \
|
48
48
|
| tr " " "\n" \
|
49
49
|
| grep -- "--$1" \
|
50
50
|
| tail -n 1 \
|
@@ -114,8 +114,8 @@ case "${1:-''}" in
|
|
114
114
|
if mysqld_status check_alive warn; then
|
115
115
|
log_end_msg 0
|
116
116
|
# Now start mysqlcheck or whatever the admin wants.
|
117
|
-
output=$(/etc/mysql/debian-start)
|
118
|
-
[ -n "$output" ] && log_action_msg "$output"
|
117
|
+
#output=$(/etc/mysql/debian-start)
|
118
|
+
#[ -n "$output" ] && log_action_msg "$output"
|
119
119
|
else
|
120
120
|
log_end_msg 1
|
121
121
|
log_failure_msg "Please take a look at the syslog"
|
@@ -0,0 +1,123 @@
|
|
1
|
+
|
2
|
+
class MySQL_Slave < Wakame::Service::Resource
|
3
|
+
|
4
|
+
def_attribute :duplicable, true
|
5
|
+
def_attribute :max_instances, {:default=>5}
|
6
|
+
|
7
|
+
def_attribute :mysqld_basedir, '/home/wakame/mysql'
|
8
|
+
def_attribute :mysqld_port, 3307
|
9
|
+
|
10
|
+
def_attribute :ebs_device, '/dev/sdn'
|
11
|
+
def_attribute :ebs_mount_option, 'noatime'
|
12
|
+
|
13
|
+
def basedir
|
14
|
+
File.join(Wakame.config.root_path, 'cluster', 'resources', 'mysql_slave')
|
15
|
+
end
|
16
|
+
|
17
|
+
def mysqld_datadir
|
18
|
+
File.expand_path('data-slave', mysqld_basedir)
|
19
|
+
end
|
20
|
+
|
21
|
+
def mysqld_log_bin
|
22
|
+
File.expand_path('mysql-bin.log', mysqld_datadir)
|
23
|
+
end
|
24
|
+
|
25
|
+
def render_config(template)
|
26
|
+
template.cp(%w(init.d/mysql-slave))
|
27
|
+
template.render(%w(conf/my.cnf))
|
28
|
+
template.chmod("init.d/mysql-slave", 0755)
|
29
|
+
end
|
30
|
+
|
31
|
+
def start(svc, action)
|
32
|
+
cond = ConditionalWait.new { |cond|
|
33
|
+
cond.wait_event(Wakame::Event::ServiceOnline) { |event|
|
34
|
+
event.instance_id == svc.instance_id
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
action.actor_request(svc.agent.agent_id,
|
39
|
+
'/service_monitor/register',
|
40
|
+
svc.instance_id,
|
41
|
+
:command, "/usr/bin/mysqladmin --defaults-file=#{svc.agent.root_path}/tmp/config/mysql_slave/conf/my.cnf ping > /dev/null") { |req|
|
42
|
+
}
|
43
|
+
|
44
|
+
opt_map = {
|
45
|
+
:aws_access_key => Wakame.config.aws_access_key,
|
46
|
+
:aws_secret_key => Wakame.config.aws_secret_key,
|
47
|
+
:ebs_device => self.ebs_device,
|
48
|
+
:master_ip => svc.cluster.fetch_mysql_master_ip,
|
49
|
+
}
|
50
|
+
svc.cluster.each_instance(MySQL_Master) { |mysql_master|
|
51
|
+
opt_map[:master_port] = mysql_master.resource.mysqld_port
|
52
|
+
opt_map[:master_ebs_volume] = mysql_master.resource.ebs_volume
|
53
|
+
opt_map[:master_mysqld_datadir] = mysql_master.resource.mysqld_datadir
|
54
|
+
opt_map[:repl_user] = mysql_master.resource.repl_user
|
55
|
+
opt_map[:repl_pass] = mysql_master.resource.repl_pass
|
56
|
+
}
|
57
|
+
|
58
|
+
action.actor_request(svc.agent.agent_id, '/mysql/take_master_snapshot', opt_map) { |req|
|
59
|
+
req.wait
|
60
|
+
Wakame.log.debug("take-master-snapshot!!")
|
61
|
+
}
|
62
|
+
|
63
|
+
action.actor_request(svc.agent.agent_id, '/system/sync') { |req|
|
64
|
+
req.wait
|
65
|
+
Wakame.log.debug("sync")
|
66
|
+
}
|
67
|
+
|
68
|
+
action.actor_request(svc.agent.agent_id, '/system/mount', self.ebs_device, self.mysqld_datadir, self.ebs_mount_option) { |req|
|
69
|
+
req.wait
|
70
|
+
Wakame.log.debug("MySQL volume was mounted: #{self.mysqld_datadir}")
|
71
|
+
}
|
72
|
+
|
73
|
+
action.actor_request(svc.agent.agent_id, '/daemon/start', 'mysql_slave', 'init.d/mysql-slave') { |req|
|
74
|
+
req.wait
|
75
|
+
Wakame.log.debug("MySQL process started")
|
76
|
+
}
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
def stop(svc, action)
|
81
|
+
cond = ConditionalWait.new { |c|
|
82
|
+
c.wait_event(Wakame::Event::ServiceOffline) { |event|
|
83
|
+
event.instance_id == svc.instance_id
|
84
|
+
}
|
85
|
+
}
|
86
|
+
action.actor_request(svc.agent.agent_id, '/daemon/stop', 'mysql_slave', 'init.d/mysql-slave') { |req| req.wait }
|
87
|
+
action.actor_request(svc.agent.agent_id, '/system/umount', self.mysqld_datadir) { |req|
|
88
|
+
req.wait
|
89
|
+
Wakame.log.debug("MySQL volume unmounted")
|
90
|
+
}
|
91
|
+
cond.wait
|
92
|
+
|
93
|
+
require 'right_aws'
|
94
|
+
ec2 = RightAws::Ec2.new(Wakame.config.aws_access_key, Wakame.config.aws_secret_key)
|
95
|
+
ec2.describe_volumes.each do |volume|
|
96
|
+
next unless volume[:aws_instance_id] == svc.agent.agent_id && volume[:aws_device] == self.ebs_device
|
97
|
+
|
98
|
+
@ebs_volume = volume[:aws_id]
|
99
|
+
|
100
|
+
# detach volume
|
101
|
+
res = ec2.detach_volume(@ebs_volume)
|
102
|
+
Wakame.log.debug("detach_volume : #{res.inspect}")
|
103
|
+
# waiting for available
|
104
|
+
cond = ConditionalWait.new { |c|
|
105
|
+
c.poll {
|
106
|
+
res = ec2.describe_volumes([@ebs_volume])[0]
|
107
|
+
res[:aws_status] == 'available'
|
108
|
+
}
|
109
|
+
}
|
110
|
+
cond.wait
|
111
|
+
|
112
|
+
# delete mysql-slave snapshot volume
|
113
|
+
res = ec2.delete_volume(@ebs_volume)
|
114
|
+
Wakame.log.debug("delete_volume : #{res.inspect}")
|
115
|
+
end
|
116
|
+
|
117
|
+
# unregister
|
118
|
+
action.actor_request(svc.agent.agent_id,
|
119
|
+
'/service_monitor/unregister',
|
120
|
+
svc.instance_id).request
|
121
|
+
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,166 @@
|
|
1
|
+
user www-data;
|
2
|
+
worker_processes 1;
|
3
|
+
|
4
|
+
error_log /var/log/nginx/error.log;
|
5
|
+
pid /var/run/nginx.pid;
|
6
|
+
|
7
|
+
events {
|
8
|
+
worker_connections 1024;
|
9
|
+
}
|
10
|
+
|
11
|
+
http {
|
12
|
+
include /etc/nginx/mime.types;
|
13
|
+
default_type application/octet-stream;
|
14
|
+
|
15
|
+
access_log /var/log/nginx/access.log;
|
16
|
+
|
17
|
+
proxy_redirect off;
|
18
|
+
proxy_set_header Host $host;
|
19
|
+
proxy_set_header X-Real-IP $remote_addr;
|
20
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
21
|
+
client_max_body_size 10m;
|
22
|
+
client_body_buffer_size 128k;
|
23
|
+
proxy_connect_timeout 1;
|
24
|
+
proxy_send_timeout 90;
|
25
|
+
proxy_read_timeout 90;
|
26
|
+
proxy_buffers 32 4k;
|
27
|
+
|
28
|
+
sendfile on;
|
29
|
+
tcp_nopush on;
|
30
|
+
|
31
|
+
#keepalive_timeout 0;
|
32
|
+
keepalive_timeout 65;
|
33
|
+
tcp_nodelay on;
|
34
|
+
|
35
|
+
gzip on;
|
36
|
+
|
37
|
+
|
38
|
+
upstream appcluster {
|
39
|
+
<%- service_cluster.each_app { |n|
|
40
|
+
next if n.status != STATUS_ONLINE
|
41
|
+
-%>
|
42
|
+
server <%= n.agent.agent_ip %>:<%= n.property.listen_port %>;
|
43
|
+
<%- } -%>
|
44
|
+
}
|
45
|
+
|
46
|
+
|
47
|
+
server {
|
48
|
+
listen 80;
|
49
|
+
server_name localhost;
|
50
|
+
|
51
|
+
access_log /var/log/nginx/localhost.access.log combined;
|
52
|
+
|
53
|
+
location / {
|
54
|
+
root /var/www/nginx-default;
|
55
|
+
index index.html index.htm;
|
56
|
+
}
|
57
|
+
|
58
|
+
location /doc {
|
59
|
+
root /usr/share;
|
60
|
+
autoindex on;
|
61
|
+
allow 127.0.0.1;
|
62
|
+
deny all;
|
63
|
+
}
|
64
|
+
|
65
|
+
location /images {
|
66
|
+
root /usr/share;
|
67
|
+
autoindex on;
|
68
|
+
}
|
69
|
+
|
70
|
+
#error_page 404 /404.html;
|
71
|
+
|
72
|
+
# redirect server error pages to the static page /50x.html
|
73
|
+
#
|
74
|
+
error_page 500 502 503 504 /50x.html;
|
75
|
+
location = /50x.html {
|
76
|
+
root /var/www/nginx-default;
|
77
|
+
}
|
78
|
+
|
79
|
+
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
|
80
|
+
#
|
81
|
+
#location ~ \.php$ {
|
82
|
+
#proxy_pass http://127.0.0.1;
|
83
|
+
#}
|
84
|
+
|
85
|
+
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
|
86
|
+
#
|
87
|
+
#location ~ \.php$ {
|
88
|
+
#fastcgi_pass 127.0.0.1:9000;
|
89
|
+
#fastcgi_index index.php;
|
90
|
+
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
|
91
|
+
#includefastcgi_params;
|
92
|
+
#}
|
93
|
+
|
94
|
+
# deny access to .htaccess files, if Apache's document root
|
95
|
+
# concurs with nginx's one
|
96
|
+
#
|
97
|
+
#location ~ /\.ht {
|
98
|
+
#deny all;
|
99
|
+
#}
|
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
|
+
}
|
118
|
+
|
119
|
+
location ~ /\.ht {
|
120
|
+
deny all;
|
121
|
+
}
|
122
|
+
}
|
123
|
+
<%- } -%>
|
124
|
+
|
125
|
+
# another virtual host using mix of IP-, name-, and port-based configuration
|
126
|
+
#
|
127
|
+
#server {
|
128
|
+
#listen 8000;
|
129
|
+
#listen somename:8080;
|
130
|
+
#server_name somename alias another.alias;
|
131
|
+
|
132
|
+
#location / {
|
133
|
+
#root html;
|
134
|
+
#index index.html index.htm;
|
135
|
+
#}
|
136
|
+
#}
|
137
|
+
|
138
|
+
|
139
|
+
# HTTPS server
|
140
|
+
#
|
141
|
+
#server {
|
142
|
+
#listen 443;
|
143
|
+
#server_name localhost;
|
144
|
+
|
145
|
+
#ssl on;
|
146
|
+
#ssl_certificate cert.pem;
|
147
|
+
#ssl_certificate_key cert.key;
|
148
|
+
|
149
|
+
#ssl_session_timeout 5m;
|
150
|
+
|
151
|
+
#ssl_protocols SSLv2 SSLv3 TLSv1;
|
152
|
+
#ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
|
153
|
+
#ssl_prefer_server_ciphers on;
|
154
|
+
|
155
|
+
#location / {
|
156
|
+
#root html;
|
157
|
+
#index index.html index.htm;
|
158
|
+
#}
|
159
|
+
#}
|
160
|
+
|
161
|
+
|
162
|
+
#include /etc/nginx/conf.d/*.conf;
|
163
|
+
#include /etc/nginx/sites-enabled/*;
|
164
|
+
}
|
165
|
+
|
166
|
+
|
@@ -0,0 +1,70 @@
|
|
1
|
+
#! /bin/sh
|
2
|
+
|
3
|
+
### BEGIN INIT INFO
|
4
|
+
# Provides: nginx
|
5
|
+
# Required-Start: $all
|
6
|
+
# Required-Stop: $all
|
7
|
+
# Default-Start: 2 3 4 5
|
8
|
+
# Default-Stop: 0 1 6
|
9
|
+
# Short-Description: starts the nginx web server
|
10
|
+
# Description: starts nginx using start-stop-daemon
|
11
|
+
### END INIT INFO
|
12
|
+
|
13
|
+
[ -n $WAKAME_ROOT ] || { echo "WAKAME_ROOT env was not set" >&2; exit 1; }
|
14
|
+
|
15
|
+
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
16
|
+
DAEMON=/usr/sbin/nginx
|
17
|
+
NAME=nginx
|
18
|
+
DESC=nginx
|
19
|
+
DAEMON_OPTS="-c $WAKAME_ROOT/tmp/config/nginx/conf/nginx.conf"
|
20
|
+
|
21
|
+
test -x $DAEMON || exit 0
|
22
|
+
|
23
|
+
# Include nginx defaults if available
|
24
|
+
if [ -f /etc/default/nginx ] ; then
|
25
|
+
. /etc/default/nginx
|
26
|
+
fi
|
27
|
+
|
28
|
+
set -e
|
29
|
+
|
30
|
+
. /lib/lsb/init-functions
|
31
|
+
|
32
|
+
case "$1" in
|
33
|
+
start)
|
34
|
+
echo -n "Starting $DESC: "
|
35
|
+
start-stop-daemon --start --oknodo --quiet --pidfile /var/run/$NAME.pid \
|
36
|
+
--exec $DAEMON -- $DAEMON_OPTS
|
37
|
+
echo "$NAME."
|
38
|
+
;;
|
39
|
+
stop)
|
40
|
+
echo -n "Stopping $DESC: "
|
41
|
+
start-stop-daemon --stop --oknodo --quiet --pidfile /var/run/$NAME.pid \
|
42
|
+
--exec $DAEMON
|
43
|
+
echo "$NAME."
|
44
|
+
;;
|
45
|
+
restart|force-reload)
|
46
|
+
echo -n "Restarting $DESC: "
|
47
|
+
start-stop-daemon --stop --quiet --pidfile \
|
48
|
+
/var/run/$NAME.pid --exec $DAEMON || true
|
49
|
+
sleep 1
|
50
|
+
start-stop-daemon --start --quiet --pidfile \
|
51
|
+
/var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS || true
|
52
|
+
echo "$NAME."
|
53
|
+
;;
|
54
|
+
reload)
|
55
|
+
echo -n "Reloading $DESC configuration: "
|
56
|
+
start-stop-daemon --stop --signal HUP --quiet --pidfile /var/run/$NAME.pid \
|
57
|
+
--exec $DAEMON
|
58
|
+
echo "$NAME."
|
59
|
+
;;
|
60
|
+
# status)
|
61
|
+
# status_of_proc -p /var/run/$NAME.pid "$DAEMON" nginx && exit 0 || exit $?
|
62
|
+
# ;;
|
63
|
+
*)
|
64
|
+
N=/etc/init.d/$NAME
|
65
|
+
echo "Usage: $N {start|stop|restart|reload|force-reload|status}" >&2
|
66
|
+
exit 1
|
67
|
+
;;
|
68
|
+
esac
|
69
|
+
|
70
|
+
exit 0
|
@@ -1,19 +1,21 @@
|
|
1
|
-
|
1
|
+
|
2
|
+
require 'wakame/rule'
|
3
|
+
|
4
|
+
class Nginx < Wakame::Service::Resource
|
2
5
|
include WebCluster::HttpLoadBalanceServer
|
3
|
-
include Wakame::Service::ApacheBasicProps
|
4
6
|
|
5
7
|
def_attribute :listen_port, {:default=>80}
|
6
8
|
def_attribute :listen_port_https, {:default=>443}
|
7
9
|
|
8
10
|
def render_config(template)
|
9
|
-
template.cp(%w(
|
10
|
-
template.render(%w(conf/
|
11
|
-
template.chmod("init.d/
|
11
|
+
template.cp(%w(init.d/nginx))
|
12
|
+
template.render(%w(conf/nginx.conf))
|
13
|
+
template.chmod("init.d/nginx", 0755)
|
12
14
|
end
|
13
15
|
|
14
16
|
def on_parent_changed(svc, action)
|
15
|
-
|
16
|
-
action
|
17
|
+
Wakame::Rule::BasicActionSet.deploy_configuration(svc)
|
18
|
+
reload(svc, action)
|
17
19
|
end
|
18
20
|
|
19
21
|
def start(svc, action)
|
@@ -24,10 +26,13 @@ class Apache_LB < Wakame::Service::Resource
|
|
24
26
|
}
|
25
27
|
|
26
28
|
request = action.actor_request(svc.agent.agent_id,
|
27
|
-
'/service_monitor/register', svc.instance_id, :pidfile, '/var/run/
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
'/service_monitor/register', svc.instance_id, :pidfile, '/var/run/nginx.pid').request
|
30
|
+
action.actor_request(svc.agent.agent_id,
|
31
|
+
'/daemon/start', "nginx", 'init.d/nginx'){ |req|
|
32
|
+
req.wait
|
33
|
+
Wakame.log.debug("#{self.class} process started")
|
34
|
+
}
|
35
|
+
|
31
36
|
cond.wait
|
32
37
|
end
|
33
38
|
|
@@ -38,9 +43,12 @@ class Apache_LB < Wakame::Service::Resource
|
|
38
43
|
}
|
39
44
|
}
|
40
45
|
|
41
|
-
|
42
|
-
|
43
|
-
|
46
|
+
action.actor_request(svc.agent.agent_id,
|
47
|
+
'/daemon/stop', 'nginx', 'init.d/nginx'){ |req|
|
48
|
+
req.wait
|
49
|
+
Wakame.log.debug("#{self.class} process stopped")
|
50
|
+
}
|
51
|
+
|
44
52
|
cond.wait
|
45
53
|
|
46
54
|
request = action.actor_request(svc.agent.agent_id,
|
@@ -48,9 +56,12 @@ class Apache_LB < Wakame::Service::Resource
|
|
48
56
|
end
|
49
57
|
|
50
58
|
def reload(svc, action)
|
51
|
-
|
52
|
-
|
53
|
-
|
59
|
+
action.actor_request(svc.agent.agent_id,
|
60
|
+
'/daemon/reload', "nginx", 'init.d/nginx'){ |req|
|
61
|
+
req.wait
|
62
|
+
Wakame.log.debug("#{self.class} process reloaded")
|
63
|
+
}
|
54
64
|
end
|
55
65
|
|
56
66
|
end
|
67
|
+
|
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.
|
4
|
+
version: 0.4.2
|
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-07-24 00:00:00 +09:00
|
14
14
|
default_executable: wakame
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -113,6 +113,36 @@ dependencies:
|
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: 1.0.0
|
115
115
|
version:
|
116
|
+
- !ruby/object:Gem::Dependency
|
117
|
+
name: rack
|
118
|
+
type: :runtime
|
119
|
+
version_requirement:
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 1.0.0
|
125
|
+
version:
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: thin
|
128
|
+
type: :runtime
|
129
|
+
version_requirement:
|
130
|
+
version_requirements: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: 1.2.2
|
135
|
+
version:
|
136
|
+
- !ruby/object:Gem::Dependency
|
137
|
+
name: json
|
138
|
+
type: :runtime
|
139
|
+
version_requirement:
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: 1.1.7
|
145
|
+
version:
|
116
146
|
description: ""
|
117
147
|
email:
|
118
148
|
- m-fujiwara@axsh.net
|
@@ -132,28 +162,6 @@ files:
|
|
132
162
|
- app_generators/wakame/templates/bin/wakame-agent
|
133
163
|
- app_generators/wakame/templates/bin/wakame-master
|
134
164
|
- app_generators/wakame/templates/bin/wakameadm
|
135
|
-
- app_generators/wakame/templates/cluster/resources/apache_app/apache_app.rb
|
136
|
-
- app_generators/wakame/templates/cluster/resources/apache_app/conf/apache2.conf
|
137
|
-
- app_generators/wakame/templates/cluster/resources/apache_app/conf/envvars-app
|
138
|
-
- app_generators/wakame/templates/cluster/resources/apache_app/conf/sites-app.conf
|
139
|
-
- app_generators/wakame/templates/cluster/resources/apache_app/conf/system-app.conf
|
140
|
-
- app_generators/wakame/templates/cluster/resources/apache_app/init.d/apache2-app
|
141
|
-
- app_generators/wakame/templates/cluster/resources/apache_lb/apache_lb.rb
|
142
|
-
- app_generators/wakame/templates/cluster/resources/apache_lb/conf/apache2.conf
|
143
|
-
- app_generators/wakame/templates/cluster/resources/apache_lb/conf/envvars-lb
|
144
|
-
- app_generators/wakame/templates/cluster/resources/apache_lb/conf/sites-lb.conf
|
145
|
-
- app_generators/wakame/templates/cluster/resources/apache_lb/conf/system-lb.conf
|
146
|
-
- app_generators/wakame/templates/cluster/resources/apache_lb/init.d/apache2-lb
|
147
|
-
- app_generators/wakame/templates/cluster/resources/apache_www/apache_www.rb
|
148
|
-
- app_generators/wakame/templates/cluster/resources/apache_www/conf/apache2.conf
|
149
|
-
- app_generators/wakame/templates/cluster/resources/apache_www/conf/envvars-www
|
150
|
-
- app_generators/wakame/templates/cluster/resources/apache_www/conf/sites-www.conf
|
151
|
-
- app_generators/wakame/templates/cluster/resources/apache_www/conf/system-www.conf
|
152
|
-
- app_generators/wakame/templates/cluster/resources/apache_www/init.d/apache2-www
|
153
|
-
- app_generators/wakame/templates/cluster/resources/ec2_elastic_ip/ec2_elastic_ip.rb
|
154
|
-
- app_generators/wakame/templates/cluster/resources/mysql_master/conf/my.cnf
|
155
|
-
- app_generators/wakame/templates/cluster/resources/mysql_master/init.d/mysql
|
156
|
-
- app_generators/wakame/templates/cluster/resources/mysql_master/mysql_master.rb
|
157
165
|
- app_generators/wakame/templates/config/boot.rb
|
158
166
|
- app_generators/wakame/templates/config/cluster.rb
|
159
167
|
- app_generators/wakame/templates/config/environments/common.rb
|
@@ -171,6 +179,7 @@ files:
|
|
171
179
|
- lib/wakame/action.rb
|
172
180
|
- lib/wakame/actions/destroy_instances.rb
|
173
181
|
- lib/wakame/actions/launch_cluster.rb
|
182
|
+
- lib/wakame/actions/launch_vm.rb
|
174
183
|
- lib/wakame/actions/migrate_service.rb
|
175
184
|
- lib/wakame/actions/propagate_instances.rb
|
176
185
|
- lib/wakame/actions/reload_service.rb
|
@@ -182,6 +191,7 @@ files:
|
|
182
191
|
- lib/wakame/actions/util.rb
|
183
192
|
- lib/wakame/actor.rb
|
184
193
|
- lib/wakame/actor/daemon.rb
|
194
|
+
- lib/wakame/actor/mysql.rb
|
185
195
|
- lib/wakame/actor/service_monitor.rb
|
186
196
|
- lib/wakame/actor/system.rb
|
187
197
|
- lib/wakame/agent.rb
|
@@ -189,12 +199,17 @@ files:
|
|
189
199
|
- lib/wakame/command.rb
|
190
200
|
- lib/wakame/command/action_status.rb
|
191
201
|
- lib/wakame/command/actor.rb
|
202
|
+
- lib/wakame/command/agent_status.rb
|
192
203
|
- lib/wakame/command/clone_service.rb
|
193
204
|
- lib/wakame/command/launch_cluster.rb
|
205
|
+
- lib/wakame/command/launch_vm.rb
|
194
206
|
- lib/wakame/command/migrate_service.rb
|
195
207
|
- lib/wakame/command/propagate_service.rb
|
208
|
+
- lib/wakame/command/reload_service.rb
|
196
209
|
- lib/wakame/command/shutdown_cluster.rb
|
210
|
+
- lib/wakame/command/shutdown_vm.rb
|
197
211
|
- lib/wakame/command/status.rb
|
212
|
+
- lib/wakame/command/stop_service.rb
|
198
213
|
- lib/wakame/command_queue.rb
|
199
214
|
- lib/wakame/configuration.rb
|
200
215
|
- lib/wakame/daemonize.rb
|
@@ -229,9 +244,6 @@ files:
|
|
229
244
|
- lib/wakame/vm_manipulator.rb
|
230
245
|
- tasks/ec2.rake
|
231
246
|
- tests/cluster.json
|
232
|
-
- tests/conf/a
|
233
|
-
- tests/conf/b
|
234
|
-
- tests/conf/c
|
235
247
|
- tests/setup_agent.rb
|
236
248
|
- tests/setup_master.rb
|
237
249
|
- tests/test_actor.rb
|
@@ -266,9 +278,16 @@ files:
|
|
266
278
|
- wakame_generators/resource/templates/apache_www/conf/system-www.conf
|
267
279
|
- wakame_generators/resource/templates/apache_www/init.d/apache2-www
|
268
280
|
- wakame_generators/resource/templates/ec2_elastic_ip/ec2_elastic_ip.rb
|
281
|
+
- wakame_generators/resource/templates/ec2_elb/ec2_elb.rb
|
269
282
|
- wakame_generators/resource/templates/mysql_master/conf/my.cnf
|
270
283
|
- wakame_generators/resource/templates/mysql_master/init.d/mysql
|
271
284
|
- wakame_generators/resource/templates/mysql_master/mysql_master.rb
|
285
|
+
- wakame_generators/resource/templates/mysql_slave/conf/my.cnf
|
286
|
+
- wakame_generators/resource/templates/mysql_slave/init.d/mysql-slave
|
287
|
+
- wakame_generators/resource/templates/mysql_slave/mysql_slave.rb
|
288
|
+
- wakame_generators/resource/templates/nginx/conf/nginx.conf
|
289
|
+
- wakame_generators/resource/templates/nginx/init.d/nginx
|
290
|
+
- wakame_generators/resource/templates/nginx/nginx.rb
|
272
291
|
has_rdoc: true
|
273
292
|
homepage: http://wakame.rubyforge.org/
|
274
293
|
post_install_message:
|