ScholarNexus-ec2onrails 0.9.10
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +180 -0
- data/COPYING +339 -0
- data/Manifest +167 -0
- data/README.textile +211 -0
- data/Rakefile +37 -0
- data/TODO +104 -0
- data/ec2onrails.gemspec +42 -0
- data/examples/Capfile +3 -0
- data/examples/deploy.rb +107 -0
- data/examples/s3.yml +9 -0
- data/lib/ec2onrails/capistrano_utils.rb +43 -0
- data/lib/ec2onrails/recipes/db.rb +359 -0
- data/lib/ec2onrails/recipes/deploy.rb +30 -0
- data/lib/ec2onrails/recipes/server.rb +489 -0
- data/lib/ec2onrails/recipes.rb +141 -0
- data/lib/ec2onrails/version.rb +31 -0
- data/lib/ec2onrails.rb +20 -0
- data/server/build-ec2onrails.sh +44 -0
- data/server/files/etc/aliases +5 -0
- data/server/files/etc/aliases.db +0 -0
- data/server/files/etc/apache2/apache2.conf +295 -0
- data/server/files/etc/apache2/conf.d/app.proxy_cluster.conf +7 -0
- data/server/files/etc/apache2/conf.d/app.proxy_frontend.conf +10 -0
- data/server/files/etc/apache2/mods-available/proxy.conf +18 -0
- data/server/files/etc/apache2/sites-available/app.common +61 -0
- data/server/files/etc/apache2/sites-available/app.custom +0 -0
- data/server/files/etc/apache2/sites-available/default +14 -0
- data/server/files/etc/apache2/sites-available/default-ssl +19 -0
- data/server/files/etc/cron.d/ec2onrails +21 -0
- data/server/files/etc/cron.daily/app +24 -0
- data/server/files/etc/cron.daily/logrotate_post +19 -0
- data/server/files/etc/cron.hourly/app +24 -0
- data/server/files/etc/cron.monthly/app +24 -0
- data/server/files/etc/cron.weekly/app +24 -0
- data/server/files/etc/denyhosts.conf +628 -0
- data/server/files/etc/dpkg/dpkg.cfg +13 -0
- data/server/files/etc/ec2onrails/README +32 -0
- data/server/files/etc/ec2onrails/balancer_members +6 -0
- data/server/files/etc/ec2onrails/roles.yml +5 -0
- data/server/files/etc/environment +2 -0
- data/server/files/etc/god/app.god +40 -0
- data/server/files/etc/god/db.god +17 -0
- data/server/files/etc/god/dkim_filter.god +20 -0
- data/server/files/etc/god/examples/have_god_daemonize.god +18 -0
- data/server/files/etc/god/master.conf +35 -0
- data/server/files/etc/god/memcache.god +15 -0
- data/server/files/etc/god/notifications.god +14 -0
- data/server/files/etc/god/system.god +34 -0
- data/server/files/etc/god/web.god +38 -0
- data/server/files/etc/init.d/ec2-every-startup +29 -0
- data/server/files/etc/init.d/ec2-first-startup +36 -0
- data/server/files/etc/init.d/god +42 -0
- data/server/files/etc/init.d/nginx +78 -0
- data/server/files/etc/init.d/set_roles +3 -0
- data/server/files/etc/logrotate.d/apache2 +16 -0
- data/server/files/etc/logrotate.d/mongrel +11 -0
- data/server/files/etc/logrotate.d/nginx +11 -0
- data/server/files/etc/memcached.conf +47 -0
- data/server/files/etc/mongrel_cluster/app.yml +9 -0
- data/server/files/etc/motd.tail +13 -0
- data/server/files/etc/mysql/my.cnf +152 -0
- data/server/files/etc/nginx/nginx.conf +305 -0
- data/server/files/etc/postfix/main.cf +4 -0
- data/server/files/etc/rcS.d/S91ec2-first-startup +1 -0
- data/server/files/etc/rcS.d/S92ec2-every-startup +1 -0
- data/server/files/etc/rcS.d/S99set_roles +1 -0
- data/server/files/etc/ssh/sshd_config +94 -0
- data/server/files/etc/sudoers +1 -0
- data/server/files/etc/sudoers.full_access +26 -0
- data/server/files/etc/sudoers.restricted_access +28 -0
- data/server/files/etc/syslog.conf +69 -0
- data/server/files/usr/bin/god +26 -0
- data/server/files/usr/local/ec2onrails/COPYING +339 -0
- data/server/files/usr/local/ec2onrails/bin/archive_file.rb +44 -0
- data/server/files/usr/local/ec2onrails/bin/backup_app_db.rb +159 -0
- data/server/files/usr/local/ec2onrails/bin/ec2_meta_data.rb +80 -0
- data/server/files/usr/local/ec2onrails/bin/exec_runner +76 -0
- data/server/files/usr/local/ec2onrails/bin/init_services.rb +71 -0
- data/server/files/usr/local/ec2onrails/bin/optimize_mysql.rb +348 -0
- data/server/files/usr/local/ec2onrails/bin/rails_env +34 -0
- data/server/files/usr/local/ec2onrails/bin/rebundle.sh +70 -0
- data/server/files/usr/local/ec2onrails/bin/restore_app_db.rb +58 -0
- data/server/files/usr/local/ec2onrails/bin/set_rails_env +40 -0
- data/server/files/usr/local/ec2onrails/bin/set_roles.rb +87 -0
- data/server/files/usr/local/ec2onrails/bin/setup_web_proxy.rb +113 -0
- data/server/files/usr/local/ec2onrails/bin/update_hostname +40 -0
- data/server/files/usr/local/ec2onrails/config +30 -0
- data/server/files/usr/local/ec2onrails/lib/aws_helper.rb +76 -0
- data/server/files/usr/local/ec2onrails/lib/god_helper.rb +129 -0
- data/server/files/usr/local/ec2onrails/lib/god_patch.rb +43 -0
- data/server/files/usr/local/ec2onrails/lib/mysql_helper.rb +101 -0
- data/server/files/usr/local/ec2onrails/lib/roles_helper.rb +151 -0
- data/server/files/usr/local/ec2onrails/lib/s3_helper.rb +99 -0
- data/server/files/usr/local/ec2onrails/lib/utils.rb +16 -0
- data/server/files/usr/local/ec2onrails/lib/vendor/ini.rb +268 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/every-startup/get-hostname.sh +23 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/README +5 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/create-dirs.sh +39 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/generate-default-web-cert-and-key.sh +49 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/misc.sh +27 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/prepare-mysql-data-dir.sh +24 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/setup-credentials.sh +29 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/setup-file-permissions.sh +30 -0
- data/server/rakefile.rb +249 -0
- data/setup.rb +1585 -0
- data/test/autobench.conf +60 -0
- data/test/spec/lib/s3_helper_spec.rb +134 -0
- data/test/spec/lib/s3_old.yml +3 -0
- data/test/spec/test_files/test1 +0 -0
- data/test/spec/test_files/test2 +0 -0
- data/test/test_app/Capfile +3 -0
- data/test/test_app/README +182 -0
- data/test/test_app/Rakefile +10 -0
- data/test/test_app/app/controllers/application.rb +7 -0
- data/test/test_app/app/controllers/db_fast_controller.rb +6 -0
- data/test/test_app/app/controllers/fast_controller.rb +5 -0
- data/test/test_app/app/controllers/slow_controller.rb +6 -0
- data/test/test_app/app/controllers/very_slow_controller.rb +6 -0
- data/test/test_app/app/helpers/application_helper.rb +3 -0
- data/test/test_app/app/helpers/db_fast_helper.rb +2 -0
- data/test/test_app/app/helpers/fast_helper.rb +2 -0
- data/test/test_app/app/helpers/slow_helper.rb +2 -0
- data/test/test_app/app/helpers/very_slow_helper.rb +2 -0
- data/test/test_app/config/boot.rb +109 -0
- data/test/test_app/config/database.yml +19 -0
- data/test/test_app/config/deploy.rb +21 -0
- data/test/test_app/config/environment.rb +60 -0
- data/test/test_app/config/environments/development.rb +21 -0
- data/test/test_app/config/environments/production.rb +18 -0
- data/test/test_app/config/environments/test.rb +19 -0
- data/test/test_app/config/routes.rb +27 -0
- data/test/test_app/db/schema.rb +7 -0
- data/test/test_app/doc/README_FOR_APP +2 -0
- data/test/test_app/public/404.html +30 -0
- data/test/test_app/public/500.html +30 -0
- data/test/test_app/public/dispatch.cgi +10 -0
- data/test/test_app/public/dispatch.fcgi +24 -0
- data/test/test_app/public/dispatch.rb +10 -0
- data/test/test_app/public/favicon.ico +0 -0
- data/test/test_app/public/images/rails.png +0 -0
- data/test/test_app/public/javascripts/application.js +2 -0
- data/test/test_app/public/javascripts/controls.js +963 -0
- data/test/test_app/public/javascripts/dragdrop.js +972 -0
- data/test/test_app/public/javascripts/effects.js +1120 -0
- data/test/test_app/public/javascripts/prototype.js +4225 -0
- data/test/test_app/public/robots.txt +1 -0
- data/test/test_app/script/about +3 -0
- data/test/test_app/script/breakpointer +3 -0
- data/test/test_app/script/console +3 -0
- data/test/test_app/script/destroy +3 -0
- data/test/test_app/script/generate +3 -0
- data/test/test_app/script/performance/benchmarker +3 -0
- data/test/test_app/script/performance/profiler +3 -0
- data/test/test_app/script/performance/request +3 -0
- data/test/test_app/script/plugin +3 -0
- data/test/test_app/script/process/inspector +3 -0
- data/test/test_app/script/process/reaper +3 -0
- data/test/test_app/script/process/spawner +3 -0
- data/test/test_app/script/runner +3 -0
- data/test/test_app/script/server +3 -0
- data/test/test_app/test/functional/db_fast_controller_test.rb +18 -0
- data/test/test_app/test/functional/fast_controller_test.rb +18 -0
- data/test/test_app/test/functional/slow_controller_test.rb +18 -0
- data/test/test_app/test/functional/very_slow_controller_test.rb +18 -0
- data/test/test_app/test/test_helper.rb +28 -0
- data/test/test_ec2onrails.rb +11 -0
- data/test/test_helper.rb +2 -0
- metadata +277 -0
@@ -0,0 +1,40 @@
|
|
1
|
+
# rolling restart idea plagiarized directly from:
|
2
|
+
# http://blog.pragmatic-it.de/articles/2008/07/09/poor-mans-rolling-restart-for-thin-god
|
3
|
+
#NOTE: this doesn't do what you think it does...
|
4
|
+
# requests are queued up at nginx and requests start to time out
|
5
|
+
restart_time = 2.seconds #how long to restart the entire cluster
|
6
|
+
rolling_delay = (restart_time / @configs.web_num_instances.to_f).ceil
|
7
|
+
@configs.web_port_range.each_with_index do |port, i|
|
8
|
+
God.watch do |w|
|
9
|
+
w.name = "mongrel_#{port}"
|
10
|
+
w.group = 'app'
|
11
|
+
w.uid = @configs.user
|
12
|
+
w.gid = @configs.group
|
13
|
+
w.autostart = false
|
14
|
+
|
15
|
+
w.start = "mongrel_rails cluster::start -C /etc/mongrel_cluster/app.yml --clean --only #{port}"
|
16
|
+
w.stop = "mongrel_rails cluster::stop -C /etc/mongrel_cluster/app.yml --clean --only #{port}"
|
17
|
+
w.restart = "sleep #{i*rolling_delay}; mongrel_rails cluster::restart -C /etc/mongrel_cluster/app.yml --clean --only #{port}"
|
18
|
+
|
19
|
+
w.pid_file = "/mnt/app/shared/log/mongrel.#{port}.pid"
|
20
|
+
w.grace = 60.seconds
|
21
|
+
|
22
|
+
default_configurations(w)
|
23
|
+
create_pid_dir(w)
|
24
|
+
restart_if_resource_hog(w, :memory_usage => 170.megabytes) do |restart|
|
25
|
+
#NOTE: this will hit every instance, meaning every minute you have a hit for every port you have a mongrel on.
|
26
|
+
# adding the port number to the call just to help with making this obvious in the logs
|
27
|
+
restart.condition(:http_response_code) do |c|
|
28
|
+
c.code_is_not = %w(200 304)
|
29
|
+
c.host = '127.0.0.1'
|
30
|
+
c.path = "/?port=#{port}"
|
31
|
+
c.port = port
|
32
|
+
c.timeout = 10.seconds
|
33
|
+
c.times = 2
|
34
|
+
c.interval = 1.minute
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
monitor_lifecycle(w)
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
God.watch do |w|
|
2
|
+
w.name = 'mysql'
|
3
|
+
w.group = 'db'
|
4
|
+
w.autostart = false
|
5
|
+
|
6
|
+
w.start = "/etc/init.d/mysql start"
|
7
|
+
w.stop = "/etc/init.d/mysql stop;"
|
8
|
+
w.restart = "/etc/init.d/mysql restart"
|
9
|
+
|
10
|
+
w.pid_file = "/var/run/mysqld/mysqld.pid"
|
11
|
+
w.grace = 60.seconds
|
12
|
+
|
13
|
+
default_configurations(w)
|
14
|
+
create_pid_dir(w)
|
15
|
+
restart_if_resource_hog(w, :memory_usage => false)
|
16
|
+
monitor_lifecycle(w)
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
if File.exists?('/etc/init.d/dkim-filter')
|
2
|
+
#we have it installed, so lets register it with God
|
3
|
+
God.watch do |w|
|
4
|
+
w.name = 'dkim_filter'
|
5
|
+
w.group = 'app'
|
6
|
+
w.autostart = false
|
7
|
+
|
8
|
+
w.start = "/etc/init.d/dkim-filter start"
|
9
|
+
w.stop = "/etc/init.d/dkim-filter stop"
|
10
|
+
w.restart = "/etc/init.d/dkim-filter restart"
|
11
|
+
|
12
|
+
w.pid_file = "/var/run/dkim-filter/dkim-filter.pid"
|
13
|
+
|
14
|
+
default_configurations(w)
|
15
|
+
create_pid_dir(w)
|
16
|
+
restart_if_resource_hog(w, :memory_usage => 20.megabytes, :cpu_usage => 10.percent)
|
17
|
+
monitor_lifecycle(w)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# here we have an example script which is not daemonized.
|
2
|
+
#
|
3
|
+
# Make sure that mq_poller requires the right libraries and runs in a loop...
|
4
|
+
|
5
|
+
God.watch do |w|
|
6
|
+
w.name = 'queue'
|
7
|
+
w.group = 'app'
|
8
|
+
|
9
|
+
w.uid = @configs.user
|
10
|
+
w.gid = @configs.group
|
11
|
+
w.autostart = false
|
12
|
+
|
13
|
+
w.start = "/usr/local/ec2onrails/bin/rails_env #{APP_ROOT}/script/mq_poller"
|
14
|
+
|
15
|
+
default_configurations(w)
|
16
|
+
restart_if_resource_hog(w)
|
17
|
+
monitor_lifecycle(w)
|
18
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# For TextMate users, change the language type (at bottom of window, next to line/column counter, to ruby)
|
2
|
+
#
|
3
|
+
applog(nil, :info, "loading /etc/god/master.conf")
|
4
|
+
|
5
|
+
require '/usr/local/ec2onrails/lib/god_helper'
|
6
|
+
require "fileutils"
|
7
|
+
|
8
|
+
include GodHelper
|
9
|
+
|
10
|
+
APP_ROOT = "/mnt/app/current"
|
11
|
+
RAILS_ENV = `/usr/local/ec2onrails/bin/rails_env`.strip
|
12
|
+
|
13
|
+
|
14
|
+
@configs = GodHelper::Configs.new
|
15
|
+
|
16
|
+
God.pid_file_directory = "/var/run/god"
|
17
|
+
God.load "/etc/god/*.god"
|
18
|
+
|
19
|
+
applog(nil, :info, "about to load application specific configs at #{APP_ROOT}/config/god/#{RAILS_ENV}/*.god")
|
20
|
+
|
21
|
+
God.load "#{APP_ROOT}/config/god/#{RAILS_ENV}/*.god"
|
22
|
+
|
23
|
+
|
24
|
+
# at the end, we want to init the correct services
|
25
|
+
# need to put it into a thread because god is not finished
|
26
|
+
# initalizing at this point, so we need to let it finish
|
27
|
+
# so we can call init_services, which calls god directly
|
28
|
+
#
|
29
|
+
# using a fork copies over the processing space, causing
|
30
|
+
# god to reload again..and again...and again...
|
31
|
+
Thread.new do
|
32
|
+
sleep(2)
|
33
|
+
applog(nil, :info, "initializing services....")
|
34
|
+
system("/usr/local/ec2onrails/bin/init_services.rb")
|
35
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
God.watch do |w|
|
2
|
+
w.name = "memcached"
|
3
|
+
w.group = 'memcache'
|
4
|
+
w.autostart = false
|
5
|
+
|
6
|
+
w.start = "/etc/init.d/memcached start"
|
7
|
+
w.stop = "/etc/init.d/memcached stop"
|
8
|
+
w.restart = "/etc/init.d/memcached restart"
|
9
|
+
w.pid_file = "/var/run/memcached.pid"
|
10
|
+
w.grace = 10.seconds
|
11
|
+
|
12
|
+
default_configurations(w)
|
13
|
+
restart_if_resource_hog(w, :memory_usage => false)
|
14
|
+
monitor_lifecycle(w)
|
15
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
God::Contacts::Email.message_settings = {
|
2
|
+
:from => 'app@localhost'
|
3
|
+
}
|
4
|
+
|
5
|
+
God::Contacts::Email.server_settings = {
|
6
|
+
:address => 'localhost',
|
7
|
+
:port => 25
|
8
|
+
}
|
9
|
+
|
10
|
+
God.contact(:email) do |c|
|
11
|
+
c.name = 'app'
|
12
|
+
c.email = 'app@localhost'
|
13
|
+
c.group = 'default'
|
14
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
God.watch do |w|
|
2
|
+
w.name = "system-checks"
|
3
|
+
w.start = true
|
4
|
+
w.interval = 10.minutes
|
5
|
+
|
6
|
+
|
7
|
+
w.behavior(:clean_pid_file)
|
8
|
+
|
9
|
+
|
10
|
+
# lifecycle
|
11
|
+
w.lifecycle do |on|
|
12
|
+
on.condition(:disk_usage) do |c|
|
13
|
+
c.mount_point = "/"
|
14
|
+
c.above = 75
|
15
|
+
end
|
16
|
+
|
17
|
+
on.condition(:disk_usage) do |c|
|
18
|
+
c.mount_point = "/mnt"
|
19
|
+
c.above = 75
|
20
|
+
end
|
21
|
+
|
22
|
+
# on.condition(:memory_usage) do |c|
|
23
|
+
# c.above = 170.megabytes
|
24
|
+
# c.times = [3, 5] # 3 out of 5 intervals
|
25
|
+
# end
|
26
|
+
|
27
|
+
on.condition(:cpu_usage) do |c|
|
28
|
+
c.above = 90.percent
|
29
|
+
c.times = [5, 8]
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
nginx_enabled = system("which nginx 2>&1 > /dev/null")
|
2
|
+
|
3
|
+
God.watch do |w|
|
4
|
+
applog(w, :info, "web: using #{nginx_enabled ? 'nginx' : 'apache2'}")
|
5
|
+
server_status_path = '/'
|
6
|
+
if nginx_enabled
|
7
|
+
w.name = "nginx"
|
8
|
+
w.start = "/etc/init.d/nginx start"
|
9
|
+
w.stop = "/etc/init.d/nginx stop"
|
10
|
+
w.restart = "/etc/init.d/nginx restart"
|
11
|
+
w.pid_file = "/var/run/nginx.pid"
|
12
|
+
server_status_path = '/nginx_status'
|
13
|
+
else
|
14
|
+
w.name = "apache"
|
15
|
+
w.start = "/etc/init.d/apache2 start"
|
16
|
+
w.stop = "/etc/init.d/apache2 stop"
|
17
|
+
w.restart = "/etc/init.d/apache2 restart"
|
18
|
+
w.pid_file = "/var/run/apache2.pid"
|
19
|
+
server_status_path = '/server-status'
|
20
|
+
end
|
21
|
+
w.grace = 30.seconds
|
22
|
+
w.group = 'web'
|
23
|
+
w.autostart = false
|
24
|
+
|
25
|
+
default_configurations(w)
|
26
|
+
restart_if_resource_hog(w, :memory_usage => 250.megabytes) do |restart|
|
27
|
+
restart.condition(:http_response_code) do |c|
|
28
|
+
c.host = '127.0.0.1'
|
29
|
+
c.port = 80
|
30
|
+
c.path = server_status_path
|
31
|
+
c.code_is_not = 200
|
32
|
+
c.timeout = 5.seconds
|
33
|
+
c.times = [3, 5] # 3 out of 5 intervals
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
monitor_lifecycle(w)
|
38
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
# This file is part of EC2 on Rails.
|
4
|
+
# http://rubyforge.org/projects/ec2onrails/
|
5
|
+
#
|
6
|
+
# Copyright 2007 Paul Dowman, http://pauldowman.com/
|
7
|
+
#
|
8
|
+
# EC2 on Rails is free software; you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# EC2 on Rails is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU General Public License
|
19
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
20
|
+
|
21
|
+
|
22
|
+
# This script runs the ec2 startup scripts
|
23
|
+
|
24
|
+
# this is an ugly hack to make sure DHCP initialization is finished:
|
25
|
+
sleep 15
|
26
|
+
|
27
|
+
for SCRIPT in `ls -I README /usr/local/ec2onrails/startup-scripts/every-startup` ; do
|
28
|
+
"/usr/local/ec2onrails/startup-scripts/every-startup/$SCRIPT"
|
29
|
+
done
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
# This file is part of EC2 on Rails.
|
4
|
+
# http://rubyforge.org/projects/ec2onrails/
|
5
|
+
#
|
6
|
+
# Copyright 2007 Paul Dowman, http://pauldowman.com/
|
7
|
+
#
|
8
|
+
# EC2 on Rails is free software; you can redistribute it and/or modify
|
9
|
+
# it under the terms of the GNU General Public License as published by
|
10
|
+
# the Free Software Foundation; either version 2 of the License, or
|
11
|
+
# (at your option) any later version.
|
12
|
+
#
|
13
|
+
# EC2 on Rails is distributed in the hope that it will be useful,
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16
|
+
# GNU General Public License for more details.
|
17
|
+
#
|
18
|
+
# You should have received a copy of the GNU General Public License
|
19
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
20
|
+
|
21
|
+
|
22
|
+
# This script runs the ec2 startup scripts
|
23
|
+
|
24
|
+
FILE=/ec2onrails-first-boot
|
25
|
+
|
26
|
+
if [ -e $FILE ] ; then
|
27
|
+
|
28
|
+
# this is an ugly hack to make sure DHCP initialization is finished:
|
29
|
+
sleep 15
|
30
|
+
|
31
|
+
for SCRIPT in `ls -I README /usr/local/ec2onrails/startup-scripts/first-startup` ; do
|
32
|
+
"/usr/local/ec2onrails/startup-scripts/first-startup/$SCRIPT"
|
33
|
+
done
|
34
|
+
|
35
|
+
rm $FILE
|
36
|
+
fi
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
#
|
3
|
+
# god Startup script for god (http://god.rubyforge.org)
|
4
|
+
#
|
5
|
+
# chkconfig: - 85 15
|
6
|
+
# description: God is an easy to configure, easy to extend monitoring \
|
7
|
+
# framework written in Ruby.
|
8
|
+
#
|
9
|
+
|
10
|
+
CONF_DIR=/etc/god
|
11
|
+
|
12
|
+
RETVAL=0
|
13
|
+
|
14
|
+
# Go no further if config directory is missing.
|
15
|
+
[ -d "$CONF_DIR" ] || exit 0
|
16
|
+
|
17
|
+
case "$1" in
|
18
|
+
start)
|
19
|
+
# Create pid directory
|
20
|
+
ruby /usr/bin/god -c $CONF_DIR/master.conf
|
21
|
+
RETVAL=$?
|
22
|
+
;;
|
23
|
+
stop)
|
24
|
+
ruby /usr/bin/god quit
|
25
|
+
RETVAL=$?
|
26
|
+
;;
|
27
|
+
restart)
|
28
|
+
ruby /usr/bin/god quit
|
29
|
+
ruby /usr/bin/god -c $CONF_DIR/master.conf
|
30
|
+
RETVAL=$?
|
31
|
+
;;
|
32
|
+
status)
|
33
|
+
ruby /usr/bin/god status
|
34
|
+
RETVAL=$?
|
35
|
+
;;
|
36
|
+
*)
|
37
|
+
echo "Usage: god {start|stop|restart|status}"
|
38
|
+
exit 1
|
39
|
+
;;
|
40
|
+
esac
|
41
|
+
|
42
|
+
exit $RETVAL
|
@@ -0,0 +1,78 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
#This is a start script for nginx. Tested on Unbuntu Edge.
|
4
|
+
#Should work on Ubuntu, Debian and probably a few other Linux distros.
|
5
|
+
#Change DAEMON and CONFIG_FILE if neccessary
|
6
|
+
|
7
|
+
PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
8
|
+
|
9
|
+
|
10
|
+
#Location of nginx binary. Change path as neccessary
|
11
|
+
DAEMON=/usr/sbin/nginx
|
12
|
+
# DAEMON=/usr/local/nginx/sbin/nginx
|
13
|
+
#Location of configuration file. Change path as neccessary
|
14
|
+
CONFIG_FILE=/etc/nginx/nginx.conf
|
15
|
+
# CONFIG_FILE=/usr/local/nginx/conf/nginx.conf
|
16
|
+
|
17
|
+
|
18
|
+
DAEMON_OPTS="-c $CONFIG_FILE"
|
19
|
+
NAME=nginx
|
20
|
+
DESC="web server"
|
21
|
+
PIDFILE=/var/run/$NAME.pid
|
22
|
+
SCRIPTNAME=/etc/init.d/$NAME
|
23
|
+
|
24
|
+
|
25
|
+
#only run if binary can be found
|
26
|
+
test -x $DAEMON || exit 0
|
27
|
+
|
28
|
+
set -e
|
29
|
+
|
30
|
+
#import init-functions
|
31
|
+
. /lib/lsb/init-functions
|
32
|
+
|
33
|
+
case "$1" in
|
34
|
+
start)
|
35
|
+
log_daemon_msg "Starting $DESC" $NAME
|
36
|
+
if ! start-stop-daemon --start --quiet\
|
37
|
+
--pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS ; then
|
38
|
+
log_end_msg 1
|
39
|
+
else
|
40
|
+
log_end_msg 0
|
41
|
+
fi
|
42
|
+
;;
|
43
|
+
stop)
|
44
|
+
log_daemon_msg "Stopping $DESC" $NAME
|
45
|
+
if start-stop-daemon --quiet --stop --oknodo --retry 30\
|
46
|
+
--pidfile $PIDFILE --exec $DAEMON; then
|
47
|
+
rm -f $PIDFILE
|
48
|
+
log_end_msg 0
|
49
|
+
else
|
50
|
+
log_end_msg 1
|
51
|
+
fi
|
52
|
+
;;
|
53
|
+
reload)
|
54
|
+
log_daemon_msg "Reloading $DESC configuration" $NAME
|
55
|
+
if start-stop-daemon --stop --signal 2 --oknodo --retry 30\
|
56
|
+
--quiet --pidfile $PIDFILE --exec $DAEMON; then
|
57
|
+
if start-stop-daemon --start --quiet \
|
58
|
+
--pidfile $PIDFILE --exec $DAEMON -- $DAEMON_OPTS ; then
|
59
|
+
log_end_msg 0
|
60
|
+
else
|
61
|
+
log_end_msg 1
|
62
|
+
fi
|
63
|
+
else
|
64
|
+
log_end_msg 1
|
65
|
+
fi
|
66
|
+
;;
|
67
|
+
restart|force-reload)
|
68
|
+
$0 stop
|
69
|
+
sleep 1
|
70
|
+
$0 start
|
71
|
+
;;
|
72
|
+
*)
|
73
|
+
echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
|
74
|
+
exit 1
|
75
|
+
;;
|
76
|
+
esac
|
77
|
+
|
78
|
+
exit 0
|
@@ -0,0 +1,16 @@
|
|
1
|
+
/mnt/log/apache2/*.log {
|
2
|
+
daily
|
3
|
+
missingok
|
4
|
+
dateext
|
5
|
+
create 640 root app
|
6
|
+
compress
|
7
|
+
notifempty
|
8
|
+
sharedscripts
|
9
|
+
extension gz
|
10
|
+
copytruncate
|
11
|
+
postrotate
|
12
|
+
if [ -f /var/run/apache2.pid ]; then
|
13
|
+
/etc/init.d/apache2 reload > /dev/null
|
14
|
+
fi
|
15
|
+
endscript
|
16
|
+
}
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# memcached default config file
|
2
|
+
# 2003 - Jay Bonci <jaybonci@debian.org>
|
3
|
+
# This configuration file is read by the start-memcached script provided as
|
4
|
+
# part of the Debian GNU/Linux distribution.
|
5
|
+
|
6
|
+
# Run memcached as a daemon. This command is implied, and is not needed for the
|
7
|
+
# daemon to run. See the README.Debian that comes with this package for more
|
8
|
+
# information.
|
9
|
+
-d
|
10
|
+
|
11
|
+
# Log memcached's output to /var/log/memcached
|
12
|
+
logfile /mnt/log/memcached.log
|
13
|
+
|
14
|
+
# Be verbose
|
15
|
+
# -v
|
16
|
+
|
17
|
+
# Be even more verbose (print client commands as well)
|
18
|
+
# -vv
|
19
|
+
|
20
|
+
# Start with a cap of 64 megs of memory. It's reasonable, and the daemon default
|
21
|
+
# Note that the daemon will grow to this size, but does not start out holding this much
|
22
|
+
# memory
|
23
|
+
-m 128
|
24
|
+
|
25
|
+
# Default connection port is 11211
|
26
|
+
-p 11211
|
27
|
+
|
28
|
+
# Run the daemon as root. The start-memcached will default to running as root if no
|
29
|
+
# -u command is present in this config file
|
30
|
+
-u nobody
|
31
|
+
|
32
|
+
# Specify which IP address to listen on. The default is to listen on all IP addresses
|
33
|
+
# This parameter is one of the only security measures that memcached has, so make sure
|
34
|
+
# it's listening on a firewalled interface.
|
35
|
+
#-l 127.0.0.1
|
36
|
+
|
37
|
+
# Limit the number of simultaneous incoming connections. The daemon default is 1024
|
38
|
+
# -c 1024
|
39
|
+
|
40
|
+
# Lock down all paged memory. Consult with the README and homepage before you do this
|
41
|
+
# -k
|
42
|
+
|
43
|
+
# Return error when memory is exhausted (rather than removing items)
|
44
|
+
# -M
|
45
|
+
|
46
|
+
# Maximize core file limit
|
47
|
+
# -r
|
@@ -0,0 +1,13 @@
|
|
1
|
+
|
2
|
+
EC2 on Rails
|
3
|
+
!!VERSION!!
|
4
|
+
http://rubyforge.org/projects/ec2onrails/
|
5
|
+
|
6
|
+
Copyright 2008 Paul Dowman, http://pauldowman.com/
|
7
|
+
|
8
|
+
Base AMI built using Eric Hammond's EC2 Ubuntu script:
|
9
|
+
http://alestic.com/
|
10
|
+
|
11
|
+
This is free software, and you are welcome to redistribute it under
|
12
|
+
certain conditions. This software comes with ABSOLUTELY NO WARRANTY.
|
13
|
+
See /usr/local/ec2onrails/COPYING for details.
|