wakame 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. data/History.txt +20 -0
  2. data/README.rdoc +63 -0
  3. data/Rakefile +86 -0
  4. data/VERSION +1 -0
  5. data/app_generators/wakame/templates/README +0 -0
  6. data/app_generators/wakame/templates/Rakefile +18 -0
  7. data/app_generators/wakame/templates/bin/wakame-agent +9 -0
  8. data/app_generators/wakame/templates/bin/wakame-master +9 -0
  9. data/app_generators/wakame/templates/bin/wakameadm +9 -0
  10. data/app_generators/wakame/templates/cluster/resources/apache_app/apache_app.rb +54 -0
  11. data/app_generators/wakame/templates/cluster/resources/apache_app/conf/apache2.conf +46 -0
  12. data/app_generators/wakame/templates/cluster/resources/apache_app/conf/envvars-app +7 -0
  13. data/app_generators/wakame/templates/cluster/resources/apache_app/conf/sites-app.conf +23 -0
  14. data/app_generators/wakame/templates/cluster/resources/apache_app/conf/system-app.conf +67 -0
  15. data/app_generators/wakame/templates/cluster/resources/apache_app/init.d/apache2-app +192 -0
  16. data/app_generators/wakame/templates/cluster/resources/apache_lb/apache_lb.rb +56 -0
  17. data/app_generators/wakame/templates/cluster/resources/apache_lb/conf/apache2.conf +46 -0
  18. data/app_generators/wakame/templates/cluster/resources/apache_lb/conf/envvars-lb +6 -0
  19. data/app_generators/wakame/templates/cluster/resources/apache_lb/conf/sites-lb.conf +54 -0
  20. data/app_generators/wakame/templates/cluster/resources/apache_lb/conf/system-lb.conf +75 -0
  21. data/app_generators/wakame/templates/cluster/resources/apache_lb/init.d/apache2-lb +192 -0
  22. data/app_generators/wakame/templates/cluster/resources/apache_www/apache_www.rb +50 -0
  23. data/app_generators/wakame/templates/cluster/resources/apache_www/conf/apache2.conf +47 -0
  24. data/app_generators/wakame/templates/cluster/resources/apache_www/conf/envvars-www +7 -0
  25. data/app_generators/wakame/templates/cluster/resources/apache_www/conf/sites-www.conf +23 -0
  26. data/app_generators/wakame/templates/cluster/resources/apache_www/conf/system-www.conf +63 -0
  27. data/app_generators/wakame/templates/cluster/resources/apache_www/init.d/apache2-www +192 -0
  28. data/app_generators/wakame/templates/cluster/resources/ec2_elastic_ip/ec2_elastic_ip.rb +39 -0
  29. data/app_generators/wakame/templates/cluster/resources/mysql_master/conf/my.cnf +154 -0
  30. data/app_generators/wakame/templates/cluster/resources/mysql_master/init.d/mysql +185 -0
  31. data/app_generators/wakame/templates/cluster/resources/mysql_master/mysql_master.rb +174 -0
  32. data/app_generators/wakame/templates/config/boot.rb +85 -0
  33. data/app_generators/wakame/templates/config/cluster.rb +64 -0
  34. data/app_generators/wakame/templates/config/environments/common.rb +0 -0
  35. data/app_generators/wakame/templates/config/environments/ec2.rb +3 -0
  36. data/app_generators/wakame/templates/config/environments/stand_alone.rb +0 -0
  37. data/app_generators/wakame/templates/config/init.d/wakame-agent +72 -0
  38. data/app_generators/wakame/templates/config/init.d/wakame-master +73 -0
  39. data/app_generators/wakame/wakame_generator.rb +124 -0
  40. data/bin/wakame +18 -0
  41. data/contrib/imagesetup.sh +77 -0
  42. data/lib/ext/eventmachine.rb +86 -0
  43. data/lib/ext/shellwords.rb +172 -0
  44. data/lib/ext/uri.rb +15 -0
  45. data/lib/wakame/action.rb +156 -0
  46. data/lib/wakame/actions/destroy_instances.rb +39 -0
  47. data/lib/wakame/actions/launch_cluster.rb +31 -0
  48. data/lib/wakame/actions/migrate_service.rb +65 -0
  49. data/lib/wakame/actions/propagate_instances.rb +95 -0
  50. data/lib/wakame/actions/reload_service.rb +21 -0
  51. data/lib/wakame/actions/scaleout_when_high_load.rb +44 -0
  52. data/lib/wakame/actions/shutdown_cluster.rb +22 -0
  53. data/lib/wakame/actions/shutdown_vm.rb +19 -0
  54. data/lib/wakame/actions/start_service.rb +64 -0
  55. data/lib/wakame/actions/stop_service.rb +49 -0
  56. data/lib/wakame/actions/util.rb +71 -0
  57. data/lib/wakame/actor/daemon.rb +37 -0
  58. data/lib/wakame/actor/service_monitor.rb +21 -0
  59. data/lib/wakame/actor/system.rb +46 -0
  60. data/lib/wakame/actor.rb +33 -0
  61. data/lib/wakame/agent.rb +226 -0
  62. data/lib/wakame/amqp_client.rb +219 -0
  63. data/lib/wakame/command/action_status.rb +62 -0
  64. data/lib/wakame/command/actor.rb +23 -0
  65. data/lib/wakame/command/clone_service.rb +12 -0
  66. data/lib/wakame/command/launch_cluster.rb +15 -0
  67. data/lib/wakame/command/migrate_service.rb +21 -0
  68. data/lib/wakame/command/propagate_service.rb +24 -0
  69. data/lib/wakame/command/shutdown_cluster.rb +15 -0
  70. data/lib/wakame/command/status.rb +81 -0
  71. data/lib/wakame/command.rb +31 -0
  72. data/lib/wakame/command_queue.rb +44 -0
  73. data/lib/wakame/configuration.rb +93 -0
  74. data/lib/wakame/daemonize.rb +96 -0
  75. data/lib/wakame/event.rb +232 -0
  76. data/lib/wakame/event_dispatcher.rb +154 -0
  77. data/lib/wakame/graph.rb +79 -0
  78. data/lib/wakame/initializer.rb +162 -0
  79. data/lib/wakame/instance_counter.rb +78 -0
  80. data/lib/wakame/logger.rb +12 -0
  81. data/lib/wakame/manager/commands.rb +134 -0
  82. data/lib/wakame/master.rb +369 -0
  83. data/lib/wakame/monitor/agent.rb +50 -0
  84. data/lib/wakame/monitor/service.rb +183 -0
  85. data/lib/wakame/monitor.rb +69 -0
  86. data/lib/wakame/packets.rb +160 -0
  87. data/lib/wakame/queue_declare.rb +14 -0
  88. data/lib/wakame/rule.rb +116 -0
  89. data/lib/wakame/rule_engine.rb +202 -0
  90. data/lib/wakame/runner/administrator_command.rb +112 -0
  91. data/lib/wakame/runner/agent.rb +81 -0
  92. data/lib/wakame/runner/master.rb +93 -0
  93. data/lib/wakame/scheduler.rb +251 -0
  94. data/lib/wakame/service.rb +914 -0
  95. data/lib/wakame/template.rb +189 -0
  96. data/lib/wakame/trigger.rb +66 -0
  97. data/lib/wakame/triggers/instance_count_update.rb +45 -0
  98. data/lib/wakame/triggers/load_history.rb +107 -0
  99. data/lib/wakame/triggers/maintain_ssh_known_hosts.rb +43 -0
  100. data/lib/wakame/triggers/process_command.rb +34 -0
  101. data/lib/wakame/triggers/shutdown_unused_vm.rb +16 -0
  102. data/lib/wakame/util.rb +569 -0
  103. data/lib/wakame/vm_manipulator.rb +186 -0
  104. data/lib/wakame.rb +59 -0
  105. data/tasks/ec2.rake +127 -0
  106. data/tests/cluster.json +3 -0
  107. data/tests/conf/a +1 -0
  108. data/tests/conf/b +1 -0
  109. data/tests/conf/c +1 -0
  110. data/tests/setup_agent.rb +39 -0
  111. data/tests/setup_master.rb +28 -0
  112. data/tests/test_actor.rb +54 -0
  113. data/tests/test_agent.rb +218 -0
  114. data/tests/test_amqp_client.rb +94 -0
  115. data/tests/test_graph.rb +36 -0
  116. data/tests/test_master.rb +167 -0
  117. data/tests/test_monitor.rb +47 -0
  118. data/tests/test_rule_engine.rb +127 -0
  119. data/tests/test_scheduler.rb +123 -0
  120. data/tests/test_service.rb +60 -0
  121. data/tests/test_template.rb +67 -0
  122. data/tests/test_uri_amqp.rb +19 -0
  123. data/tests/test_util.rb +71 -0
  124. data/wakame_generators/resource/resource_generator.rb +54 -0
  125. data/wakame_generators/resource/templates/apache_app/apache_app.rb +60 -0
  126. data/wakame_generators/resource/templates/apache_app/conf/apache2.conf +46 -0
  127. data/wakame_generators/resource/templates/apache_app/conf/envvars-app +7 -0
  128. data/wakame_generators/resource/templates/apache_app/conf/sites-app.conf +23 -0
  129. data/wakame_generators/resource/templates/apache_app/conf/system-app.conf +67 -0
  130. data/wakame_generators/resource/templates/apache_app/init.d/apache2-app +192 -0
  131. data/wakame_generators/resource/templates/apache_lb/apache_lb.rb +67 -0
  132. data/wakame_generators/resource/templates/apache_lb/conf/apache2.conf +46 -0
  133. data/wakame_generators/resource/templates/apache_lb/conf/envvars-lb +6 -0
  134. data/wakame_generators/resource/templates/apache_lb/conf/sites-lb.conf +54 -0
  135. data/wakame_generators/resource/templates/apache_lb/conf/system-lb.conf +75 -0
  136. data/wakame_generators/resource/templates/apache_lb/init.d/apache2-lb +192 -0
  137. data/wakame_generators/resource/templates/apache_www/apache_www.rb +56 -0
  138. data/wakame_generators/resource/templates/apache_www/conf/apache2.conf +47 -0
  139. data/wakame_generators/resource/templates/apache_www/conf/envvars-www +7 -0
  140. data/wakame_generators/resource/templates/apache_www/conf/sites-www.conf +23 -0
  141. data/wakame_generators/resource/templates/apache_www/conf/system-www.conf +63 -0
  142. data/wakame_generators/resource/templates/apache_www/init.d/apache2-www +192 -0
  143. data/wakame_generators/resource/templates/ec2_elastic_ip/ec2_elastic_ip.rb +39 -0
  144. data/wakame_generators/resource/templates/mysql_master/conf/my.cnf +154 -0
  145. data/wakame_generators/resource/templates/mysql_master/init.d/mysql +185 -0
  146. data/wakame_generators/resource/templates/mysql_master/mysql_master.rb +119 -0
  147. metadata +289 -0
@@ -0,0 +1,47 @@
1
+ #ServerRoot "/etc/apache2"
2
+ #ServerRoot "/home/wakame/config/apache2"
3
+ ServerRoot "<%= agent.root_path %>/tmp/config/apache_www/conf"
4
+
5
+
6
+ LockFile /var/lock/apache2/accept.lock
7
+ PidFile ${APACHE_PID_FILE}
8
+
9
+ User ${APACHE_RUN_USER}
10
+ Group ${APACHE_RUN_GROUP}
11
+
12
+ Include ${SYSTEM_INCLUDE_FILE}
13
+
14
+ LoadModule mime_module /usr/lib/apache2/modules/mod_mime.so
15
+ <IfModule mod_mime.c>
16
+ TypesConfig /etc/mime.types
17
+
18
+ AddType application/x-compress .Z
19
+ AddType application/x-gzip .gz .tgz
20
+ AddType application/x-bzip2 .bz2
21
+ </IfModule>
22
+
23
+ AccessFileName .htaccess
24
+ <Files ~ "^\.ht">
25
+ Order allow,deny
26
+ Deny from all
27
+ </Files>
28
+
29
+ ErrorLog ${APACHE_ERROR_LOG_FILE}
30
+
31
+ ServerTokens Full
32
+ ServerSignature On
33
+
34
+ #
35
+ # The following directives define some format nicknames for use with
36
+ # a CustomLog directive (see below).
37
+ # If you are behind a reverse proxy, you might want to change %h into %{X-Forwarded-For}i
38
+ #
39
+ <IfModule mod_log_config.c>
40
+ LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
41
+ LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined_proxy
42
+ LogFormat "%h %l %u %t \"%r\" %>s %b" common
43
+ LogFormat "%{Referer}i -> %U" referer
44
+ LogFormat "%{User-agent}i" agent
45
+ </IfModule>
46
+
47
+ Include ${SITES_INCLUDE_FILE}
@@ -0,0 +1,7 @@
1
+ export APACHE_RUN_USER=www-data
2
+ export APACHE_RUN_GROUP=www-data
3
+ export APACHE_PID_FILE=/var/run/apache2-www.pid
4
+ export APACHE_ACCESS_LOG_FILE=/var/log/apache2/access-www.log
5
+ export APACHE_ERROR_LOG_FILE=/var/log/apache2/error-www.log
6
+ export SYSTEM_INCLUDE_FILE=system-www.conf
7
+ export SITES_INCLUDE_FILE=sites-www.conf
@@ -0,0 +1,23 @@
1
+ NameVirtualHost *:<%= property.listen_port %>
2
+
3
+ # Wild Card Virtual Host
4
+ #<VirtualHost *:<%= property.listen_port %>>
5
+ #DocumentRoot /var/www
6
+ #
7
+ #LogLevel warn
8
+ #CustomLog /var/log/apache2/access-www.log combined
9
+ #ErrorLog /var/log/apache2/error-www.log
10
+ #
11
+ #</VirtualHost>
12
+
13
+ <%- cluster.virtual_hosts.each { |vh| -%>
14
+ <VirtualHost *:<%= property.listen_port %>>
15
+ ServerName <%= vh.server_name %>
16
+ DocumentRoot /home/wakame/apps/development/test/public
17
+
18
+ LogLevel warn
19
+ CustomLog /var/log/apache2/access-www.log combined
20
+ ErrorLog /var/log/apache2/error-www.log
21
+
22
+ </VirtualHost>
23
+ <%- } -%>
@@ -0,0 +1,63 @@
1
+ Timeout 300
2
+ KeepAlive Off
3
+ #MaxKeepAliveRequests 100
4
+ #KeepAliveTimeout 15
5
+
6
+ <IfModule mpm_prefork_module>
7
+ StartServers 5
8
+ MinSpareServers 5
9
+ MaxSpareServers 10
10
+ MaxClients 150
11
+ MaxRequestsPerChild 0
12
+ </IfModule>
13
+
14
+ <IfModule mpm_worker_module>
15
+ StartServers 2
16
+ MaxClients 150
17
+ MinSpareThreads 25
18
+ MaxSpareThreads 75
19
+ ThreadsPerChild 25
20
+ MaxRequestsPerChild 0
21
+ </IfModule>
22
+
23
+
24
+ LoadModule alias_module /usr/lib/apache2/modules/mod_alias.so
25
+ LoadModule auth_basic_module /usr/lib/apache2/modules/mod_auth_basic.so
26
+ LoadModule authn_file_module /usr/lib/apache2/modules/mod_authn_file.so
27
+ LoadModule authz_default_module /usr/lib/apache2/modules/mod_authz_default.so
28
+ LoadModule authz_groupfile_module /usr/lib/apache2/modules/mod_authz_groupfile.so
29
+ LoadModule authz_host_module /usr/lib/apache2/modules/mod_authz_host.so
30
+ LoadModule authz_user_module /usr/lib/apache2/modules/mod_authz_user.so
31
+ LoadModule env_module /usr/lib/apache2/modules/mod_env.so
32
+ LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
33
+ LoadModule setenvif_module /usr/lib/apache2/modules/mod_setenvif.so
34
+ LoadModule status_module /usr/lib/apache2/modules/mod_status.so
35
+ LoadModule info_module /usr/lib/apache2/modules/mod_info.so
36
+
37
+
38
+ ### Port configuration
39
+ Listen <%= property.listen_port %>
40
+
41
+ #<IfModule mod_ssl.c>
42
+ # Listen 443
43
+ #</IfModule>
44
+
45
+
46
+ <IfModule mod_status.c>
47
+ <Location /server-status>
48
+ SetHandler server-status
49
+ Order deny,allow
50
+ Deny from all
51
+ Allow from 127.0.0.1 localhost.localdomain localhost ip6-localhost
52
+ </Location>
53
+ </IfModule>
54
+
55
+ <IfModule mod_info.c>
56
+ <Location /server-info>
57
+ SetHandler server-info
58
+ Order deny,allow
59
+ Deny from all
60
+ Allow from 127.0.0.1 localhost.localdomain localhost ip6-localhost
61
+ </Location>
62
+ </IfModule>
63
+
@@ -0,0 +1,192 @@
1
+ #!/bin/sh -e
2
+
3
+ [ -n $WAKAME_ROOT ] || { echo "WAKAME_ROOT env was not set" >&2; exit 1; }
4
+
5
+ ENV="env -i LANG=C PATH=/usr/local/bin:/usr/bin:/bin"
6
+
7
+ SERVER_ROOT="$WAKAME_ROOT/tmp/config/apache_www/conf"
8
+ INITSCRIPT=`basename $0`
9
+ DEF=`echo ${INITSCRIPT#apache2-} | tr '[:lower:]' '[:upper:]'`
10
+ APACHE_ENVVARS="$SERVER_ROOT/envvars-`echo $DEF | tr '[:upper:]' '[:lower:]'`"
11
+ APACHE_ARGS="-D$DEF -f $SERVER_ROOT/apache2.conf"
12
+
13
+ [ $DEF = "APACHE2" ] && { echo "Apache server type is undefined" >&2; exit 1; }
14
+
15
+ #[ `ls -1 /etc/apache2/sites-enabled/ | wc -l | sed -e 's/ *//;'` -eq 0 ] && \
16
+ #echo "You haven't enabled any sites yet, so I'm not starting apache2." && \
17
+ #echo "To add and enable a host, use addhost and enhost." && exit 0
18
+
19
+ #edit /etc/default/apache2 to change this.
20
+ HTCACHECLEAN_RUN=auto
21
+ HTCACHECLEAN_MODE=daemon
22
+ HTCACHECLEAN_SIZE=300M
23
+ HTCACHECLEAN_DAEMON_INTERVAL=120
24
+ HTCACHECLEAN_PATH=/var/cache/apache2/mod_disk_cache
25
+ HTCACHECLEAN_OPTIONS=""
26
+
27
+ set -e
28
+ if [ -x /usr/sbin/apache2 ] ; then
29
+ HAVE_APACHE2=1
30
+ else
31
+ echo "No apache MPM package installed"
32
+ exit 0
33
+ fi
34
+
35
+ . /lib/lsb/init-functions
36
+
37
+ test -f /etc/default/rcS && . /etc/default/rcS
38
+ #test -f /etc/default/apache2 && . /etc/default/apache2
39
+
40
+ APACHE2CTL="$ENV APACHE_ENVVARS=$APACHE_ENVVARS /usr/sbin/apache2ctl $APACHE_ARGS"
41
+ CONFIG_TEST="$APACHE2CTL -t"
42
+ HTCACHECLEAN="$ENV /usr/sbin/htcacheclean"
43
+
44
+ check_htcacheclean() {
45
+ [ "$HTCACHECLEAN_MODE" = "daemon" ] || return 1
46
+
47
+ [ "$HTCACHECLEAN_RUN" = "yes" ] && return 0
48
+
49
+ [ "$HTCACHECLEAN_RUN" = "auto" \
50
+ -a -e /etc/apache2/mods-enabled/disk_cache.load ] && return 0
51
+
52
+ return 1
53
+ }
54
+
55
+ start_htcacheclean() {
56
+ $HTCACHECLEAN $HTCACHECLEAN_OPTIONS -d$HTCACHECLEAN_DAEMON_INTERVAL \
57
+ -i -p$HTCACHECLEAN_PATH -l$HTCACHECLEAN_SIZE
58
+
59
+ }
60
+
61
+ stop_htcacheclean() {
62
+ killall htcacheclean 2> /dev/null || echo ...not running
63
+ }
64
+
65
+ pidof_apache() {
66
+ # if pidof is null for some reasons the script exits automagically
67
+ # classified as good/unknown feature
68
+ PIDS=`pidof apache2` || true
69
+
70
+ PFILE=`. $APACHE_ENVVARS ; echo $APACHE_PID_FILE`
71
+ if [ -z "$PFILE" ] ; then
72
+ echo ERROR: APACHE_PID_FILE needs to be defined in $APACHE_ENVVARS >&2
73
+ exit 2
74
+ fi
75
+
76
+ [ -e $PFILE ] && PIDS2=`cat $PFILE`
77
+
78
+ # if there is a pid we need to verify that belongs to apache2
79
+ # for real
80
+ for i in $PIDS; do
81
+ if [ "$i" = "$PIDS2" ]; then
82
+ # in this case the pid stored in the
83
+ # pidfile matches one of the pidof apache
84
+ # so a simple kill will make it
85
+ echo $i
86
+ return 0
87
+ fi
88
+ done
89
+ return 1
90
+ }
91
+
92
+ apache_stop() {
93
+ if `$APACHE2CTL -t > /dev/null 2>&1`; then
94
+ # if the config is ok than we just stop normaly
95
+ $APACHE2CTL -k graceful-stop
96
+ else
97
+ # if we are here something is broken and we need to try
98
+ # to exit as nice and clean as possible
99
+ PID=$(pidof_apache)
100
+
101
+ if [ "${PID}" ]; then
102
+ # in this case it is everything nice and dandy
103
+ # and we kill apache2
104
+ log_warning_msg "We failed to correctly shutdown apache, so we're now killing all running apache processes. This is almost certainly suboptimal, so please make sure your system is working as you'd expect now!"
105
+ kill $PID
106
+ elif [ "$(pidof apache2)" ]; then
107
+ if [ "$VERBOSE" != no ]; then
108
+ echo " ... failed!"
109
+ echo "You may still have some apache2 processes running. There are"
110
+ echo "processes named 'apache2' which do not match your pid file,"
111
+ echo "and in the name of safety, we've left them alone. Please review"
112
+ echo "the situation by hand."
113
+ fi
114
+ return 1
115
+ fi
116
+ fi
117
+ }
118
+
119
+ # Stupid hack to keep lintian happy. (Warrk! Stupidhack!).
120
+ case $1 in
121
+ start)
122
+ log_daemon_msg "Starting web server" "apache2"
123
+ if $APACHE2CTL -k start; then
124
+ #if check_htcacheclean ; then
125
+ # log_progress_msg htcacheclean
126
+ # start_htcacheclean || log_end_msg 1
127
+ #fi
128
+ log_end_msg 0
129
+ else
130
+ log_end_msg 1
131
+ fi
132
+ ;;
133
+ stop)
134
+ #if check_htcacheclean ; then
135
+ # log_daemon_msg "Stopping web server" "htcacheclean"
136
+ # stop_htcacheclean
137
+ # log_progress_msg "apache2"
138
+ #else
139
+ log_daemon_msg "Stopping web server" "apache2"
140
+ #fi
141
+ if apache_stop; then
142
+ log_end_msg 0
143
+ else
144
+ log_end_msg 1
145
+ fi
146
+ ;;
147
+ reload | force-reload)
148
+ if ! $APACHE2CTL -t > /dev/null 2>&1; then
149
+ $APACHE2CTL -t || true
150
+ log_end_msg 1
151
+ exit 1
152
+ fi
153
+ log_daemon_msg "Reloading web server config" "apache2"
154
+ if pidof_apache > /dev/null ; then
155
+ if $APACHE2CTL -k graceful $2 ; then
156
+ log_end_msg 0
157
+ else
158
+ log_end_msg 1
159
+ fi
160
+ fi
161
+ ;;
162
+ restart)
163
+ #if check_htcacheclean ; then
164
+ # log_daemon_msg "Restarting web server" "htcacheclean"
165
+ # stop_htcacheclean
166
+ # log_progress_msg apache2
167
+ #else
168
+ log_daemon_msg "Restarting web server" "apache2"
169
+ #fi
170
+ if ! apache_stop; then
171
+ log_end_msg 1 || true
172
+ fi
173
+ sleep 5
174
+ if $APACHE2CTL -k start; then
175
+ #if check_htcacheclean ; then
176
+ # start_htcacheclean || log_end_msg 1
177
+ #fi
178
+ log_end_msg 0
179
+ else
180
+ log_end_msg 1
181
+ fi
182
+ ;;
183
+ configtest)
184
+ echo $APACHE2CTL -t -DDUMP_MODULES -DDUMP_VHOSTS
185
+ $APACHE2CTL -t -DDUMP_MODULES -DDUMP_VHOSTS
186
+ $APACHE2CTL -l
187
+ ;;
188
+ *)
189
+ log_success_msg "Usage: /etc/init.d/$INITSCRIPT {start|stop|restart|reload|force-reload|configtest}"
190
+ exit 1
191
+ ;;
192
+ esac
@@ -0,0 +1,39 @@
1
+ class Ec2ElasticIp < Wakame::Service::Resource
2
+
3
+ def_attribute :elastic_ip, ''
4
+ def_attribute :require_agent, false
5
+
6
+ def on_parent_changed(svc, action)
7
+ start(svc, action)
8
+ end
9
+
10
+ def start(svc, action)
11
+ require 'right_aws'
12
+ ec2 = RightAws::Ec2.new(Wakame.config.aws_access_key, Wakame.config.aws_secret_key)
13
+
14
+ puts svc.parent_instances.size.to_s
15
+ a = svc.parent_instances.first
16
+
17
+ puts "#{a.class}, a.agent=#{a.agent}"
18
+ Wakame.log.info("Associating the Elastic IP #{self.elastic_ip} to #{a.agent.attr[:instance_id]}")
19
+ ec2.associate_address(a.agent.attr[:instance_id], self.elastic_ip)
20
+ EM.barrier {
21
+ svc.update_status(Wakame::Service::STATUS_ONLINE)
22
+ }
23
+ end
24
+
25
+ def stop(svc, action)
26
+ require 'right_aws'
27
+ ec2 = RightAws::Ec2.new(Wakame.config.aws_access_key, Wakame.config.aws_secret_key)
28
+
29
+ a = svc.parent_instances.first
30
+
31
+ #Wakame.log.info("Disassociating the Elastic IP #{self.elastic_ip} from #{a.agent.attr[:instance_id]}")
32
+ #ec2.disassociate_address(self.elastic_ip)
33
+ EM.barrier {
34
+ svc.update_status(Wakame::Service::STATUS_OFFLINE)
35
+ }
36
+
37
+ end
38
+
39
+ end
@@ -0,0 +1,154 @@
1
+ #
2
+ # The MySQL database server configuration file.
3
+ #
4
+ # You can copy this to one of:
5
+ # - "/etc/mysql/my.cnf" to set global options,
6
+ # - "~/.my.cnf" to set user-specific options.
7
+ #
8
+ # One can use all long options that the program supports.
9
+ # Run program with --help to get a list of available options and with
10
+ # --print-defaults to see which it would actually understand and use.
11
+ #
12
+ # For explanations see
13
+ # http://dev.mysql.com/doc/mysql/en/server-system-variables.html
14
+
15
+ # This will be passed to all mysql clients
16
+ # It has been reported that passwords should be enclosed with ticks/quotes
17
+ # escpecially if they contain "#" chars...
18
+ # Remember to edit /etc/mysql/debian.cnf when changing the socket location.
19
+ [client]
20
+ port = <%= property.mysqld_port %>
21
+ socket = /var/run/mysqld/mysqld.sock
22
+
23
+ # Here is entries for some specific programs
24
+ # The following values assume you have at least 32M ram
25
+
26
+ # This was formally known as [safe_mysqld]. Both versions are currently parsed.
27
+ [mysqld_safe]
28
+ socket = /var/run/mysqld/mysqld.sock
29
+ nice = 0
30
+
31
+ [mysqld]
32
+ #
33
+ # * Basic Settings
34
+ #
35
+
36
+ #
37
+ # * IMPORTANT
38
+ # If you make changes to these settings and your system uses apparmor, you may
39
+ # also need to also adjust /etc/apparmor.d/usr.sbin.mysqld.
40
+ #
41
+
42
+ user = mysql
43
+ pid-file = /var/run/mysqld/mysqld.pid
44
+ socket = /var/run/mysqld/mysqld.sock
45
+ port = <%= property.mysqld_port %>
46
+ basedir = /usr
47
+ datadir = <%= property.mysqld_datadir %>
48
+ tmpdir = /tmp
49
+ language = /usr/share/mysql/english
50
+ skip-external-locking
51
+ #
52
+ # Instead of skip-networking the default is now to listen only on
53
+ # localhost which is more compatible and is not less secure.
54
+ #bind-address = 127.0.0.1
55
+ #
56
+ # * Fine Tuning
57
+ #
58
+ key_buffer = 16M
59
+ max_allowed_packet = 16M
60
+ thread_stack = 128K
61
+ thread_cache_size = 8
62
+ #max_connections = 100
63
+ #table_cache = 64
64
+ #thread_concurrency = 10
65
+ #
66
+ # * Query Cache Configuration
67
+ #
68
+ query_cache_limit = 1M
69
+ query_cache_size = 16M
70
+ #
71
+ # * Logging and Replication
72
+ #
73
+ # Both location gets rotated by the cronjob.
74
+ # 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
+ #
78
+ # Error logging goes to syslog. This is a Debian improvement :)
79
+ #
80
+ # Here you can see queries with especially long duration
81
+ log_slow_queries = /var/log/mysql/mysql-slow.log
82
+ long_query_time = 2
83
+ #log-queries-not-using-indexes
84
+ #
85
+ # The following can be used as easy to replay backup logs or for replication.
86
+ # note: if you are setting up a replication slave, see README.Debian about
87
+ # other settings you may need to change.
88
+ server-id = <%= property.mysqld_server_id %>
89
+ log_bin = <%= property.mysqld_log_bin %>
90
+ #expire_logs_days = 10
91
+ #max_binlog_size = 100M
92
+ #binlog_do_db = include_database_name
93
+ #binlog_ignore_db = include_database_name
94
+ #
95
+ # * BerkeleyDB
96
+ #
97
+ # Using BerkeleyDB is now discouraged as its support will cease in 5.1.12.
98
+ skip-bdb
99
+ #
100
+ # * InnoDB
101
+ #
102
+ # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
103
+ # Read the manual for more InnoDB related options. There are many!
104
+ # You might want to disable InnoDB to shrink the mysqld process by circa 100MB.
105
+ #skip-innodb
106
+ #
107
+ # * Security Features
108
+ #
109
+ # Read the manual, too, if you want chroot!
110
+ # chroot = /var/lib/mysql/
111
+ #
112
+ # For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
113
+ #
114
+ # ssl-ca=/etc/mysql/cacert.pem
115
+ # ssl-cert=/etc/mysql/server-cert.pem
116
+ # ssl-key=/etc/mysql/server-key.pem
117
+
118
+ innodb_flush_method=O_DIRECT
119
+ wait_timeout=60
120
+ skip-name-resolve
121
+
122
+
123
+
124
+
125
+
126
+ [mysqldump]
127
+ quick
128
+ quote-names
129
+ max_allowed_packet = 16M
130
+
131
+ [mysql]
132
+ #no-auto-rehash # faster start of mysql but no tab completition
133
+
134
+ [isamchk]
135
+ key_buffer = 16M
136
+
137
+ #
138
+ # * NDB Cluster
139
+ #
140
+ # See /usr/share/doc/mysql-server-*/README.Debian for more information.
141
+ #
142
+ # The following configuration is read by the NDB Data Nodes (ndbd processes)
143
+ # not from the NDB Management Nodes (ndb_mgmd processes).
144
+ #
145
+ # [MYSQL_CLUSTER]
146
+ # ndb-connectstring=127.0.0.1
147
+
148
+
149
+ #
150
+ # * IMPORTANT: Additional settings that can override those from this file!
151
+ # The files must end with '.cnf', otherwise they'll be ignored.
152
+ #
153
+ #!includedir /etc/mysql/conf.d/
154
+