wakame 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +20 -0
- data/README.rdoc +63 -0
- data/Rakefile +86 -0
- data/VERSION +1 -0
- data/app_generators/wakame/templates/README +0 -0
- data/app_generators/wakame/templates/Rakefile +18 -0
- data/app_generators/wakame/templates/bin/wakame-agent +9 -0
- data/app_generators/wakame/templates/bin/wakame-master +9 -0
- data/app_generators/wakame/templates/bin/wakameadm +9 -0
- data/app_generators/wakame/templates/cluster/resources/apache_app/apache_app.rb +54 -0
- data/app_generators/wakame/templates/cluster/resources/apache_app/conf/apache2.conf +46 -0
- data/app_generators/wakame/templates/cluster/resources/apache_app/conf/envvars-app +7 -0
- data/app_generators/wakame/templates/cluster/resources/apache_app/conf/sites-app.conf +23 -0
- data/app_generators/wakame/templates/cluster/resources/apache_app/conf/system-app.conf +67 -0
- data/app_generators/wakame/templates/cluster/resources/apache_app/init.d/apache2-app +192 -0
- data/app_generators/wakame/templates/cluster/resources/apache_lb/apache_lb.rb +56 -0
- data/app_generators/wakame/templates/cluster/resources/apache_lb/conf/apache2.conf +46 -0
- data/app_generators/wakame/templates/cluster/resources/apache_lb/conf/envvars-lb +6 -0
- data/app_generators/wakame/templates/cluster/resources/apache_lb/conf/sites-lb.conf +54 -0
- data/app_generators/wakame/templates/cluster/resources/apache_lb/conf/system-lb.conf +75 -0
- data/app_generators/wakame/templates/cluster/resources/apache_lb/init.d/apache2-lb +192 -0
- data/app_generators/wakame/templates/cluster/resources/apache_www/apache_www.rb +50 -0
- data/app_generators/wakame/templates/cluster/resources/apache_www/conf/apache2.conf +47 -0
- data/app_generators/wakame/templates/cluster/resources/apache_www/conf/envvars-www +7 -0
- data/app_generators/wakame/templates/cluster/resources/apache_www/conf/sites-www.conf +23 -0
- data/app_generators/wakame/templates/cluster/resources/apache_www/conf/system-www.conf +63 -0
- data/app_generators/wakame/templates/cluster/resources/apache_www/init.d/apache2-www +192 -0
- data/app_generators/wakame/templates/cluster/resources/ec2_elastic_ip/ec2_elastic_ip.rb +39 -0
- data/app_generators/wakame/templates/cluster/resources/mysql_master/conf/my.cnf +154 -0
- data/app_generators/wakame/templates/cluster/resources/mysql_master/init.d/mysql +185 -0
- data/app_generators/wakame/templates/cluster/resources/mysql_master/mysql_master.rb +174 -0
- data/app_generators/wakame/templates/config/boot.rb +85 -0
- data/app_generators/wakame/templates/config/cluster.rb +64 -0
- data/app_generators/wakame/templates/config/environments/common.rb +0 -0
- data/app_generators/wakame/templates/config/environments/ec2.rb +3 -0
- data/app_generators/wakame/templates/config/environments/stand_alone.rb +0 -0
- data/app_generators/wakame/templates/config/init.d/wakame-agent +72 -0
- data/app_generators/wakame/templates/config/init.d/wakame-master +73 -0
- data/app_generators/wakame/wakame_generator.rb +124 -0
- data/bin/wakame +18 -0
- data/contrib/imagesetup.sh +77 -0
- data/lib/ext/eventmachine.rb +86 -0
- data/lib/ext/shellwords.rb +172 -0
- data/lib/ext/uri.rb +15 -0
- data/lib/wakame/action.rb +156 -0
- data/lib/wakame/actions/destroy_instances.rb +39 -0
- data/lib/wakame/actions/launch_cluster.rb +31 -0
- data/lib/wakame/actions/migrate_service.rb +65 -0
- data/lib/wakame/actions/propagate_instances.rb +95 -0
- data/lib/wakame/actions/reload_service.rb +21 -0
- data/lib/wakame/actions/scaleout_when_high_load.rb +44 -0
- data/lib/wakame/actions/shutdown_cluster.rb +22 -0
- data/lib/wakame/actions/shutdown_vm.rb +19 -0
- data/lib/wakame/actions/start_service.rb +64 -0
- data/lib/wakame/actions/stop_service.rb +49 -0
- data/lib/wakame/actions/util.rb +71 -0
- data/lib/wakame/actor/daemon.rb +37 -0
- data/lib/wakame/actor/service_monitor.rb +21 -0
- data/lib/wakame/actor/system.rb +46 -0
- data/lib/wakame/actor.rb +33 -0
- data/lib/wakame/agent.rb +226 -0
- data/lib/wakame/amqp_client.rb +219 -0
- data/lib/wakame/command/action_status.rb +62 -0
- data/lib/wakame/command/actor.rb +23 -0
- data/lib/wakame/command/clone_service.rb +12 -0
- data/lib/wakame/command/launch_cluster.rb +15 -0
- data/lib/wakame/command/migrate_service.rb +21 -0
- data/lib/wakame/command/propagate_service.rb +24 -0
- data/lib/wakame/command/shutdown_cluster.rb +15 -0
- data/lib/wakame/command/status.rb +81 -0
- data/lib/wakame/command.rb +31 -0
- data/lib/wakame/command_queue.rb +44 -0
- data/lib/wakame/configuration.rb +93 -0
- data/lib/wakame/daemonize.rb +96 -0
- data/lib/wakame/event.rb +232 -0
- data/lib/wakame/event_dispatcher.rb +154 -0
- data/lib/wakame/graph.rb +79 -0
- data/lib/wakame/initializer.rb +162 -0
- data/lib/wakame/instance_counter.rb +78 -0
- data/lib/wakame/logger.rb +12 -0
- data/lib/wakame/manager/commands.rb +134 -0
- data/lib/wakame/master.rb +369 -0
- data/lib/wakame/monitor/agent.rb +50 -0
- data/lib/wakame/monitor/service.rb +183 -0
- data/lib/wakame/monitor.rb +69 -0
- data/lib/wakame/packets.rb +160 -0
- data/lib/wakame/queue_declare.rb +14 -0
- data/lib/wakame/rule.rb +116 -0
- data/lib/wakame/rule_engine.rb +202 -0
- data/lib/wakame/runner/administrator_command.rb +112 -0
- data/lib/wakame/runner/agent.rb +81 -0
- data/lib/wakame/runner/master.rb +93 -0
- data/lib/wakame/scheduler.rb +251 -0
- data/lib/wakame/service.rb +914 -0
- data/lib/wakame/template.rb +189 -0
- data/lib/wakame/trigger.rb +66 -0
- data/lib/wakame/triggers/instance_count_update.rb +45 -0
- data/lib/wakame/triggers/load_history.rb +107 -0
- data/lib/wakame/triggers/maintain_ssh_known_hosts.rb +43 -0
- data/lib/wakame/triggers/process_command.rb +34 -0
- data/lib/wakame/triggers/shutdown_unused_vm.rb +16 -0
- data/lib/wakame/util.rb +569 -0
- data/lib/wakame/vm_manipulator.rb +186 -0
- data/lib/wakame.rb +59 -0
- data/tasks/ec2.rake +127 -0
- data/tests/cluster.json +3 -0
- data/tests/conf/a +1 -0
- data/tests/conf/b +1 -0
- data/tests/conf/c +1 -0
- data/tests/setup_agent.rb +39 -0
- data/tests/setup_master.rb +28 -0
- data/tests/test_actor.rb +54 -0
- data/tests/test_agent.rb +218 -0
- data/tests/test_amqp_client.rb +94 -0
- data/tests/test_graph.rb +36 -0
- data/tests/test_master.rb +167 -0
- data/tests/test_monitor.rb +47 -0
- data/tests/test_rule_engine.rb +127 -0
- data/tests/test_scheduler.rb +123 -0
- data/tests/test_service.rb +60 -0
- data/tests/test_template.rb +67 -0
- data/tests/test_uri_amqp.rb +19 -0
- data/tests/test_util.rb +71 -0
- data/wakame_generators/resource/resource_generator.rb +54 -0
- data/wakame_generators/resource/templates/apache_app/apache_app.rb +60 -0
- data/wakame_generators/resource/templates/apache_app/conf/apache2.conf +46 -0
- data/wakame_generators/resource/templates/apache_app/conf/envvars-app +7 -0
- data/wakame_generators/resource/templates/apache_app/conf/sites-app.conf +23 -0
- data/wakame_generators/resource/templates/apache_app/conf/system-app.conf +67 -0
- data/wakame_generators/resource/templates/apache_app/init.d/apache2-app +192 -0
- data/wakame_generators/resource/templates/apache_lb/apache_lb.rb +67 -0
- data/wakame_generators/resource/templates/apache_lb/conf/apache2.conf +46 -0
- data/wakame_generators/resource/templates/apache_lb/conf/envvars-lb +6 -0
- data/wakame_generators/resource/templates/apache_lb/conf/sites-lb.conf +54 -0
- data/wakame_generators/resource/templates/apache_lb/conf/system-lb.conf +75 -0
- data/wakame_generators/resource/templates/apache_lb/init.d/apache2-lb +192 -0
- data/wakame_generators/resource/templates/apache_www/apache_www.rb +56 -0
- data/wakame_generators/resource/templates/apache_www/conf/apache2.conf +47 -0
- data/wakame_generators/resource/templates/apache_www/conf/envvars-www +7 -0
- data/wakame_generators/resource/templates/apache_www/conf/sites-www.conf +23 -0
- data/wakame_generators/resource/templates/apache_www/conf/system-www.conf +63 -0
- data/wakame_generators/resource/templates/apache_www/init.d/apache2-www +192 -0
- data/wakame_generators/resource/templates/ec2_elastic_ip/ec2_elastic_ip.rb +39 -0
- data/wakame_generators/resource/templates/mysql_master/conf/my.cnf +154 -0
- data/wakame_generators/resource/templates/mysql_master/init.d/mysql +185 -0
- data/wakame_generators/resource/templates/mysql_master/mysql_master.rb +119 -0
- metadata +289 -0
data/History.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
== 0.4.0 2009-06-26
|
2
|
+
|
3
|
+
* Actor and Monitor plugin support for Agent.
|
4
|
+
|
5
|
+
* Changed the deployment procedure for configuration/script files of each resource.
|
6
|
+
|
7
|
+
* Restructured the source code.
|
8
|
+
|
9
|
+
* Project folder generators using rubigen.
|
10
|
+
|
11
|
+
* Changed the deployment procedure for configuration/script files of each resource.
|
12
|
+
|
13
|
+
* Renamed major data classes. And renaming is still on-going.
|
14
|
+
|
15
|
+
* Gem packaging.
|
16
|
+
|
17
|
+
== 0.3.0 2009-04-22
|
18
|
+
|
19
|
+
* 1 major enhancement:
|
20
|
+
* Initial release
|
data/README.rdoc
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
= Wakame
|
2
|
+
|
3
|
+
* http://wakame.rubyforge.org/
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
* Wakame is a framework to simplify the complex virtual machine manipulation over multiple instances in Clound envrionment. This project aims to provide the management/monitoring services with server/daemon configuration set to build scalable web applications.
|
8
|
+
|
9
|
+
== SYNOPSIS:
|
10
|
+
|
11
|
+
*
|
12
|
+
|
13
|
+
== REQUIREMENTS:
|
14
|
+
|
15
|
+
* eventmachine
|
16
|
+
* amqp
|
17
|
+
* daemons
|
18
|
+
* amazon-ec2
|
19
|
+
* right_aws
|
20
|
+
* log4r
|
21
|
+
* jeweler
|
22
|
+
|
23
|
+
== INSTALL:
|
24
|
+
|
25
|
+
* gem install wakame
|
26
|
+
* wakame /path/to/yourproj
|
27
|
+
% cd /path/to/yourproj
|
28
|
+
% ./script/generate resource apache_lb
|
29
|
+
% ./script/generate resource apache_app
|
30
|
+
% ./script/generate resource apache_www
|
31
|
+
% ./script/generate resource mysql_master
|
32
|
+
|
33
|
+
Then edit config/cluster.rb to add above them all.
|
34
|
+
|
35
|
+
% sudo ./config/init.d/wakame-master start
|
36
|
+
% sudo ./config/init.d/wakame-agent start
|
37
|
+
|
38
|
+
== LICENSE:
|
39
|
+
|
40
|
+
(Apache License, Version 2.0)
|
41
|
+
|
42
|
+
Copyright (c) 2009 axsh co., LTD
|
43
|
+
Copyright (c) 2009 Masahiro Fujiwara <m-fujiwara_at_axsh.net>
|
44
|
+
|
45
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
46
|
+
you may not use this file except in compliance with the License.
|
47
|
+
You may obtain a copy of the License at
|
48
|
+
|
49
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
50
|
+
|
51
|
+
Unless required by applicable law or agreed to in writing, software
|
52
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
53
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
54
|
+
See the License for the specific language governing permissions and
|
55
|
+
limitations under the License.
|
56
|
+
|
57
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
58
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
59
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
60
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
61
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
62
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
63
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rake'
|
4
|
+
require 'rake/clean'
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'jeweler'
|
8
|
+
Jeweler::Tasks.new do |gem|
|
9
|
+
gem.name = "wakame"
|
10
|
+
gem.summary = %q{A distributed service framework on top of Cloud environments.}
|
11
|
+
gem.description = <<__END__
|
12
|
+
__END__
|
13
|
+
gem.email = ["m-fujiwara@axsh.net"]
|
14
|
+
gem.homepage = "http://wakame.rubyforge.org/"
|
15
|
+
gem.authors = ["axsh co.,Ltd.", "Masahiro Fujiwara"]
|
16
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
17
|
+
gem.rubyforge_project = 'wakame'
|
18
|
+
gem.executables = ['wakame']
|
19
|
+
[['amqp','>= 0.6.0'],
|
20
|
+
['amazon-ec2','>= 0.3.6'],
|
21
|
+
['right_aws','>= 1.10.0'],
|
22
|
+
['eventmachine','>= 0.12.8'],
|
23
|
+
['rake', '>= 0.8.7'],
|
24
|
+
['log4r', '>= 1.0.5'],
|
25
|
+
['daemons', '>= 1.0.10'],
|
26
|
+
['rubigen', '>= 1.5.2'],
|
27
|
+
['jeweler', '>= 1.0.0']
|
28
|
+
].each { |i|
|
29
|
+
gem.add_dependency(i[0], i[1])
|
30
|
+
}
|
31
|
+
gem.files = FileList['app_generators/**/*',
|
32
|
+
'wakame_generators/**/*',
|
33
|
+
'contrib/**/*',
|
34
|
+
'lib/**/*.rb',
|
35
|
+
'bin/*',
|
36
|
+
'[A-Z]*',
|
37
|
+
'tasks/**/*',
|
38
|
+
'tests/**/*'].to_a
|
39
|
+
end
|
40
|
+
|
41
|
+
rescue LoadError
|
42
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
43
|
+
end
|
44
|
+
|
45
|
+
require 'rake/testtask'
|
46
|
+
Rake::TestTask.new(:test) do |test|
|
47
|
+
test.libs << 'lib' << 'test'
|
48
|
+
test.pattern = 'test/**/*_test.rb'
|
49
|
+
test.verbose = true
|
50
|
+
end
|
51
|
+
|
52
|
+
begin
|
53
|
+
require 'rcov/rcovtask'
|
54
|
+
Rcov::RcovTask.new do |test|
|
55
|
+
test.libs << 'test'
|
56
|
+
test.pattern = 'test/**/*_test.rb'
|
57
|
+
test.verbose = true
|
58
|
+
end
|
59
|
+
rescue LoadError
|
60
|
+
task :rcov do
|
61
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
task :default => :test
|
67
|
+
|
68
|
+
require 'rake/rdoctask'
|
69
|
+
Rake::RDocTask.new do |rdoc|
|
70
|
+
if File.exist?('VERSION.yml')
|
71
|
+
config = YAML.load(File.read('VERSION.yml'))
|
72
|
+
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
73
|
+
else
|
74
|
+
version = ""
|
75
|
+
end
|
76
|
+
|
77
|
+
rdoc.rdoc_dir = 'rdoc'
|
78
|
+
rdoc.title = "wakame #{version}"
|
79
|
+
rdoc.rdoc_files.include('README*')
|
80
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
81
|
+
end
|
82
|
+
|
83
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
84
|
+
|
85
|
+
# task :default => [:spec, :features]
|
86
|
+
# vim: syntax=Ruby
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.4.0
|
File without changes
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
|
3
|
+
Wakame::Bootstrap.boot!
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
begin
|
7
|
+
require 'rake'
|
8
|
+
rescue LoadError
|
9
|
+
puts 'This script should only be accessed via the "rake" command.'
|
10
|
+
puts 'Installation: gem install rake -y'
|
11
|
+
exit
|
12
|
+
end
|
13
|
+
require 'rake/clean'
|
14
|
+
|
15
|
+
#Dir['tasks/**/*.rake'].each { |t| load t }
|
16
|
+
|
17
|
+
# task :default => [:spec, :features]
|
18
|
+
# vim: syntax=Ruby
|
@@ -0,0 +1,54 @@
|
|
1
|
+
class Apache_APP < Wakame::Service::Resource
|
2
|
+
include Wakame::Service::ApacheBasicProps
|
3
|
+
include WebCluster::HttpAppServer
|
4
|
+
|
5
|
+
def_attribute :listen_port, {:default=>8001}
|
6
|
+
def_attribute :listen_port_https, {:default=>443}
|
7
|
+
def_attribute :max_instance, {:default=>5}
|
8
|
+
|
9
|
+
def render_config(template)
|
10
|
+
template.cp(%w(conf/envvars-app init.d/apache2-app))
|
11
|
+
template.render(%w(conf/system-app.conf conf/apache2.conf conf/sites-app.conf))
|
12
|
+
template.chmod("init.d/apache2-app", 0755)
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
def start(svc, action)
|
17
|
+
cond = ConditionalWait.new { |cond|
|
18
|
+
cond.wait_event(Wakame::Event::ServiceOnline) { |event|
|
19
|
+
event.instance_id == svc.instance_id
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
request = action.actor_request(svc.agent.agent_id,
|
24
|
+
'/service_monitor/register', svc.instance_id, :pidfile, '/var/run/apache2-app.pid').request
|
25
|
+
request = action.actor_request(svc.agent.agent_id,
|
26
|
+
'/daemon/start', "apache_app", 'init.d/apache2-app').request
|
27
|
+
#request.wait
|
28
|
+
cond.wait
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
def stop(svc, action)
|
33
|
+
cond = ConditionalWait.new { |cond|
|
34
|
+
cond.wait_event(Wakame::Event::ServiceOffline) { |event|
|
35
|
+
event.instance_id == svc.instance_id
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
request = action.actor_request(svc.agent.agent_id,
|
40
|
+
'/daemon/stop', 'apache_app', 'init.d/apache2-app').request
|
41
|
+
#request.wait
|
42
|
+
cond.wait
|
43
|
+
|
44
|
+
request = action.actor_request(svc.agent.agent_id,
|
45
|
+
'/service_monitor/unregister', svc.instance_id ).request
|
46
|
+
end
|
47
|
+
|
48
|
+
def reload(svc, action)
|
49
|
+
request = action.actor_request(svc.agent.agent_id,
|
50
|
+
'/daemon/reload', "apache_app", 'init.d/apache2-app').request
|
51
|
+
request.wait
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
#ServerRoot "/etc/apache2"
|
2
|
+
#ServerRoot "/home/wakame/config/apache2"
|
3
|
+
ServerRoot "<%= agent.root_path %>/tmp/config/apache_app/conf"
|
4
|
+
|
5
|
+
LockFile /var/lock/apache2/accept.lock
|
6
|
+
PidFile ${APACHE_PID_FILE}
|
7
|
+
|
8
|
+
User ${APACHE_RUN_USER}
|
9
|
+
Group ${APACHE_RUN_GROUP}
|
10
|
+
|
11
|
+
Include ${SYSTEM_INCLUDE_FILE}
|
12
|
+
|
13
|
+
LoadModule mime_module /usr/lib/apache2/modules/mod_mime.so
|
14
|
+
<IfModule mod_mime.c>
|
15
|
+
TypesConfig /etc/mime.types
|
16
|
+
|
17
|
+
AddType application/x-compress .Z
|
18
|
+
AddType application/x-gzip .gz .tgz
|
19
|
+
AddType application/x-bzip2 .bz2
|
20
|
+
</IfModule>
|
21
|
+
|
22
|
+
AccessFileName .htaccess
|
23
|
+
<Files ~ "^\.ht">
|
24
|
+
Order allow,deny
|
25
|
+
Deny from all
|
26
|
+
</Files>
|
27
|
+
|
28
|
+
ErrorLog ${APACHE_ERROR_LOG_FILE}
|
29
|
+
|
30
|
+
ServerTokens Full
|
31
|
+
ServerSignature On
|
32
|
+
|
33
|
+
#
|
34
|
+
# The following directives define some format nicknames for use with
|
35
|
+
# a CustomLog directive (see below).
|
36
|
+
# If you are behind a reverse proxy, you might want to change %h into %{X-Forwarded-For}i
|
37
|
+
#
|
38
|
+
<IfModule mod_log_config.c>
|
39
|
+
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
|
40
|
+
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined_proxy
|
41
|
+
LogFormat "%h %l %u %t \"%r\" %>s %b" common
|
42
|
+
LogFormat "%{Referer}i -> %U" referer
|
43
|
+
LogFormat "%{User-agent}i" agent
|
44
|
+
</IfModule>
|
45
|
+
|
46
|
+
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-app.pid
|
4
|
+
export APACHE_ACCESS_LOG_FILE=/var/log/apache2/access-app.log
|
5
|
+
export APACHE_ERROR_LOG_FILE=/var/log/apache2/error-app.log
|
6
|
+
export SYSTEM_INCLUDE_FILE=system-app.conf
|
7
|
+
export SITES_INCLUDE_FILE=sites-app.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-app.log combined
|
9
|
+
#ErrorLog /var/log/apache2/error-app.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
|
+
RailsEnv development
|
18
|
+
|
19
|
+
LogLevel warn
|
20
|
+
CustomLog /var/log/apache2/access-app.log combined
|
21
|
+
ErrorLog /var/log/apache2/error-app.log
|
22
|
+
</VirtualHost>
|
23
|
+
<%- } -%>
|
@@ -0,0 +1,67 @@
|
|
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 10
|
11
|
+
MaxRequestsPerChild 5000
|
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
|
+
LoadModule passenger_module /usr/local/gems/gems/passenger-2.2.1/ext/apache2/mod_passenger.so
|
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
|
+
|
64
|
+
<IfModule mod_passenger.c>
|
65
|
+
PassengerRoot /usr/local/gems/gems/passenger-2.2.1
|
66
|
+
PassengerRuby "/usr/local/bin/passenger_ruby.sh"
|
67
|
+
</IfModule>
|
@@ -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_app/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,56 @@
|
|
1
|
+
class Apache_LB < Wakame::Service::Resource
|
2
|
+
include WebCluster::HttpLoadBalanceServer
|
3
|
+
include Wakame::Service::ApacheBasicProps
|
4
|
+
|
5
|
+
def_attribute :listen_port, {:default=>80}
|
6
|
+
def_attribute :listen_port_https, {:default=>443}
|
7
|
+
|
8
|
+
def render_config(template)
|
9
|
+
template.cp(%w(conf/envvars-lb init.d/apache2-lb))
|
10
|
+
template.render(%w(conf/system-lb.conf conf/apache2.conf conf/sites-lb.conf))
|
11
|
+
template.chmod("init.d/apache2-lb", 0755)
|
12
|
+
end
|
13
|
+
|
14
|
+
def on_parent_changed(svc, action)
|
15
|
+
action.deploy_configuration(svc_inst)
|
16
|
+
action.trigger_action(Rule::ReloadService.new(svc_inst))
|
17
|
+
end
|
18
|
+
|
19
|
+
def start(svc, action)
|
20
|
+
cond = ConditionalWait.new { |cond|
|
21
|
+
cond.wait_event(Wakame::Event::ServiceOnline) { |event|
|
22
|
+
event.instance_id == svc.instance_id
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
request = action.actor_request(svc.agent.agent_id,
|
27
|
+
'/service_monitor/register', svc.instance_id, :pidfile, '/var/run/apache2-lb.pid').request
|
28
|
+
request = action.actor_request(svc.agent.agent_id,
|
29
|
+
'/daemon/start', "apache_lb", 'init.d/apache2-lb').request
|
30
|
+
#request.wait
|
31
|
+
cond.wait
|
32
|
+
end
|
33
|
+
|
34
|
+
def stop(svc, action)
|
35
|
+
cond = ConditionalWait.new { |cond|
|
36
|
+
cond.wait_event(Wakame::Event::ServiceOffline) { |event|
|
37
|
+
event.instance_id == svc.instance_id
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
request = action.actor_request(svc.agent.agent_id,
|
42
|
+
'/daemon/stop', 'apache_lb', 'init.d/apache2-lb').request
|
43
|
+
#request.wait
|
44
|
+
cond.wait
|
45
|
+
|
46
|
+
request = action.actor_request(svc.agent.agent_id,
|
47
|
+
'/service_monitor/unregister', svc.instance_id ).request
|
48
|
+
end
|
49
|
+
|
50
|
+
def reload(svc, action)
|
51
|
+
request = action.actor_request(svc.agent.agent_id,
|
52
|
+
'/daemon/reload', "apache_lb", 'init.d/apache2-lb').request
|
53
|
+
request.wait
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|