wakame 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. data/History.txt +18 -0
  2. data/README.rdoc +2 -4
  3. data/Rakefile +4 -1
  4. data/VERSION +1 -1
  5. data/app_generators/wakame/templates/config/cluster.rb +36 -0
  6. data/app_generators/wakame/wakame_generator.rb +1 -0
  7. data/lib/wakame/action.rb +19 -34
  8. data/lib/wakame/actions/launch_cluster.rb +6 -3
  9. data/lib/wakame/actions/launch_vm.rb +57 -0
  10. data/lib/wakame/actions/migrate_service.rb +6 -25
  11. data/lib/wakame/actions/propagate_instances.rb +16 -41
  12. data/lib/wakame/actions/reload_service.rb +2 -2
  13. data/lib/wakame/actions/shutdown_cluster.rb +4 -0
  14. data/lib/wakame/actions/start_service.rb +30 -9
  15. data/lib/wakame/actions/stop_service.rb +1 -4
  16. data/lib/wakame/actions/util.rb +0 -24
  17. data/lib/wakame/actor/mysql.rb +106 -0
  18. data/lib/wakame/actor/service_monitor.rb +10 -0
  19. data/lib/wakame/actor/system.rb +19 -9
  20. data/lib/wakame/actor.rb +1 -1
  21. data/lib/wakame/agent.rb +23 -17
  22. data/lib/wakame/command/action_status.rb +7 -38
  23. data/lib/wakame/command/agent_status.rb +18 -0
  24. data/lib/wakame/command/launch_cluster.rb +0 -4
  25. data/lib/wakame/command/launch_vm.rb +11 -0
  26. data/lib/wakame/command/migrate_service.rb +12 -9
  27. data/lib/wakame/command/propagate_service.rb +15 -7
  28. data/lib/wakame/command/reload_service.rb +21 -0
  29. data/lib/wakame/command/shutdown_cluster.rb +0 -5
  30. data/lib/wakame/command/shutdown_vm.rb +20 -0
  31. data/lib/wakame/command/status.rb +6 -66
  32. data/lib/wakame/command/stop_service.rb +31 -0
  33. data/lib/wakame/command.rb +3 -0
  34. data/lib/wakame/command_queue.rb +76 -5
  35. data/lib/wakame/configuration.rb +6 -1
  36. data/lib/wakame/event.rb +6 -5
  37. data/lib/wakame/event_dispatcher.rb +5 -3
  38. data/lib/wakame/initializer.rb +1 -1
  39. data/lib/wakame/master.rb +14 -10
  40. data/lib/wakame/monitor/agent.rb +1 -6
  41. data/lib/wakame/monitor/service.rb +13 -1
  42. data/lib/wakame/packets.rb +51 -13
  43. data/lib/wakame/rule_engine.rb +7 -18
  44. data/lib/wakame/runner/administrator_command.rb +517 -46
  45. data/lib/wakame/service.rb +104 -173
  46. data/lib/wakame/trigger.rb +1 -10
  47. data/lib/wakame/triggers/process_command.rb +9 -2
  48. data/lib/wakame/util.rb +21 -21
  49. data/lib/wakame/vm_manipulator.rb +1 -0
  50. data/tests/test_service.rb +30 -6
  51. data/wakame_generators/resource/templates/ec2_elb/ec2_elb.rb +80 -0
  52. data/wakame_generators/resource/templates/mysql_master/conf/my.cnf +3 -1
  53. data/wakame_generators/resource/templates/mysql_master/init.d/mysql +3 -3
  54. data/wakame_generators/resource/templates/mysql_master/mysql_master.rb +11 -12
  55. data/{app_generators/wakame/templates/cluster/resources/mysql_master → wakame_generators/resource/templates/mysql_slave}/conf/my.cnf +19 -9
  56. data/{app_generators/wakame/templates/cluster/resources/mysql_master/init.d/mysql → wakame_generators/resource/templates/mysql_slave/init.d/mysql-slave} +4 -4
  57. data/wakame_generators/resource/templates/mysql_slave/mysql_slave.rb +123 -0
  58. data/wakame_generators/resource/templates/nginx/conf/nginx.conf +166 -0
  59. data/wakame_generators/resource/templates/nginx/init.d/nginx +70 -0
  60. data/{app_generators/wakame/templates/cluster/resources/apache_lb/apache_lb.rb → wakame_generators/resource/templates/nginx/nginx.rb} +28 -17
  61. metadata +46 -27
  62. data/app_generators/wakame/templates/cluster/resources/apache_app/apache_app.rb +0 -54
  63. data/app_generators/wakame/templates/cluster/resources/apache_app/conf/apache2.conf +0 -46
  64. data/app_generators/wakame/templates/cluster/resources/apache_app/conf/envvars-app +0 -7
  65. data/app_generators/wakame/templates/cluster/resources/apache_app/conf/sites-app.conf +0 -23
  66. data/app_generators/wakame/templates/cluster/resources/apache_app/conf/system-app.conf +0 -67
  67. data/app_generators/wakame/templates/cluster/resources/apache_app/init.d/apache2-app +0 -192
  68. data/app_generators/wakame/templates/cluster/resources/apache_lb/conf/apache2.conf +0 -46
  69. data/app_generators/wakame/templates/cluster/resources/apache_lb/conf/envvars-lb +0 -6
  70. data/app_generators/wakame/templates/cluster/resources/apache_lb/conf/sites-lb.conf +0 -54
  71. data/app_generators/wakame/templates/cluster/resources/apache_lb/conf/system-lb.conf +0 -75
  72. data/app_generators/wakame/templates/cluster/resources/apache_lb/init.d/apache2-lb +0 -192
  73. data/app_generators/wakame/templates/cluster/resources/apache_www/apache_www.rb +0 -50
  74. data/app_generators/wakame/templates/cluster/resources/apache_www/conf/apache2.conf +0 -47
  75. data/app_generators/wakame/templates/cluster/resources/apache_www/conf/envvars-www +0 -7
  76. data/app_generators/wakame/templates/cluster/resources/apache_www/conf/sites-www.conf +0 -23
  77. data/app_generators/wakame/templates/cluster/resources/apache_www/conf/system-www.conf +0 -63
  78. data/app_generators/wakame/templates/cluster/resources/apache_www/init.d/apache2-www +0 -192
  79. data/app_generators/wakame/templates/cluster/resources/ec2_elastic_ip/ec2_elastic_ip.rb +0 -39
  80. data/app_generators/wakame/templates/cluster/resources/mysql_master/mysql_master.rb +0 -174
  81. data/tests/conf/a +0 -1
  82. data/tests/conf/b +0 -1
  83. data/tests/conf/c +0 -1
@@ -1,192 +0,0 @@
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_lb/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
@@ -1,50 +0,0 @@
1
- class Apache_WWW < Wakame::Service::Resource
2
- include Wakame::Service::ApacheBasicProps
3
- include WebCluster::HttpAssetServer
4
-
5
- def_attribute :listen_port, {:default=>8000}
6
- def_attribute :max_instances, {:default=>5}
7
-
8
- def render_config(template)
9
- template.cp(%w(conf/envvars-www init.d/apache2-www))
10
- template.render(%w(conf/system-www.conf conf/sites-www.conf conf/apache2.conf))
11
- template.chmod("init.d/apache2-www", 0755)
12
- end
13
-
14
- def start(svc, action)
15
- cond = ConditionalWait.new { |cond|
16
- cond.wait_event(Wakame::Event::ServiceOnline) { |event|
17
- event.instance_id == svc.instance_id
18
- }
19
- }
20
-
21
- request = action.actor_request(svc.agent.agent_id,
22
- '/service_monitor/register', svc.instance_id, :pidfile, '/var/run/apache2-www.pid').request
23
- request = action.actor_request(svc.agent.agent_id,
24
- '/daemon/start', "apache_www", 'init.d/apache2-www').request
25
- #request.wait
26
- cond.wait
27
- end
28
-
29
- def stop(svc, action)
30
- cond = ConditionalWait.new { |cond|
31
- cond.wait_event(Wakame::Event::ServiceOffline) { |event|
32
- event.instance_id == svc.instance_id
33
- }
34
- }
35
-
36
- request = action.actor_request(svc.agent.agent_id,
37
- '/daemon/stop', 'apache_www', 'init.d/apache2-www').request
38
- #request.wait
39
- cond.wait
40
-
41
- request = action.actor_request(svc.agent.agent_id,
42
- '/service_monitor/unregister', svc.instance_id ).request
43
- end
44
-
45
- def reload(svc, action)
46
- request = action.actor_request('/daemon/reload', 'apache_www', 'init.d/apache2-www').request
47
- request.wait
48
- end
49
-
50
- end
@@ -1,47 +0,0 @@
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}
@@ -1,7 +0,0 @@
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
@@ -1,23 +0,0 @@
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
- <%- } -%>
@@ -1,63 +0,0 @@
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
-
@@ -1,192 +0,0 @@
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
@@ -1,39 +0,0 @@
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