pauldowman-ec2onrails 0.9.10.1 → 0.9.10.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +2 -2
- data/ec2onrails.gemspec +3 -3
- data/lib/ec2onrails/recipes/server.rb +15 -13
- data/lib/ec2onrails/version.rb +1 -1
- data/server/files/etc/cron.daily/logrotate_post +6 -0
- data/server/files/etc/god/db_primary.god +1 -2
- data/server/files/etc/god/dkim_filter.god +0 -2
- data/server/files/etc/god/master.conf +6 -2
- data/server/files/etc/god/memcache.god +0 -1
- data/server/files/etc/god/notifications.god +2 -5
- data/server/files/etc/god/proxy.god +16 -2
- data/server/files/etc/god/system.god +9 -6
- data/server/files/etc/god/web.god +0 -2
- data/server/files/etc/logrotate.d/nginx +4 -5
- data/server/files/etc/logrotate.d/rails +8 -0
- data/server/files/etc/logrotate.d/varnish +14 -0
- data/server/files/etc/nginx/nginx.conf.erb +11 -2
- data/server/files/usr/local/ec2onrails/bin/init_services +1 -1
- data/server/files/usr/local/ec2onrails/config +1 -1
- data/server/files/usr/local/ec2onrails/lib/god_helper.rb +37 -39
- data/server/rakefile.rb +7 -5
- metadata +7 -6
- data/server/files/etc/god/examples/have_god_daemonize.god +0 -18
- data/server/files/etc/logrotate.d/mongrel +0 -11
data/Manifest
CHANGED
@@ -33,7 +33,6 @@ server/files/etc/environment
|
|
33
33
|
server/files/etc/event.d/god
|
34
34
|
server/files/etc/god/db_primary.god
|
35
35
|
server/files/etc/god/dkim_filter.god
|
36
|
-
server/files/etc/god/examples/have_god_daemonize.god
|
37
36
|
server/files/etc/god/master.conf
|
38
37
|
server/files/etc/god/memcache.god
|
39
38
|
server/files/etc/god/notifications.god
|
@@ -43,8 +42,9 @@ server/files/etc/god/web.god
|
|
43
42
|
server/files/etc/init.d/ec2-every-startup
|
44
43
|
server/files/etc/init.d/ec2-first-startup
|
45
44
|
server/files/etc/init.d/nginx
|
46
|
-
server/files/etc/logrotate.d/mongrel
|
47
45
|
server/files/etc/logrotate.d/nginx
|
46
|
+
server/files/etc/logrotate.d/rails
|
47
|
+
server/files/etc/logrotate.d/varnish
|
48
48
|
server/files/etc/memcached.conf
|
49
49
|
server/files/etc/motd.tail
|
50
50
|
server/files/etc/mysql/my.cnf
|
data/ec2onrails.gemspec
CHANGED
@@ -5,15 +5,15 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{ec2onrails}
|
8
|
-
s.version = "0.9.10.
|
8
|
+
s.version = "0.9.10.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Paul Dowman, Adam Greene"]
|
12
|
-
s.date = %q{2009-
|
12
|
+
s.date = %q{2009-08-06}
|
13
13
|
s.description = %q{Client-side libraries (Capistrano tasks) for managing and deploying to EC2 on Rails servers.}
|
14
14
|
s.email = %q{paul@pauldowman.com}
|
15
15
|
s.extra_rdoc_files = ["CHANGELOG", "lib/ec2onrails/capistrano_utils.rb", "lib/ec2onrails/recipes/db.rb", "lib/ec2onrails/recipes/deploy.rb", "lib/ec2onrails/recipes/server.rb", "lib/ec2onrails/recipes.rb", "lib/ec2onrails/version.rb", "lib/ec2onrails.rb", "README.textile"]
|
16
|
-
s.files = ["CHANGELOG", "COPYING", "echoe_config.rb", "examples/Capfile", "examples/deploy.rb", "examples/s3.yml", "lib/ec2onrails/capistrano_utils.rb", "lib/ec2onrails/recipes/db.rb", "lib/ec2onrails/recipes/deploy.rb", "lib/ec2onrails/recipes/server.rb", "lib/ec2onrails/recipes.rb", "lib/ec2onrails/version.rb", "lib/ec2onrails.rb", "Manifest", "Rakefile", "README.textile", "server/build", "server/files/etc/aliases", "server/files/etc/cron.d/ec2onrails", "server/files/etc/cron.daily/app", "server/files/etc/cron.daily/logrotate_post", "server/files/etc/cron.hourly/app", "server/files/etc/cron.monthly/app", "server/files/etc/cron.weekly/app", "server/files/etc/default/varnish", "server/files/etc/default/varnishncsa", "server/files/etc/denyhosts.conf", "server/files/etc/dpkg/dpkg.cfg", "server/files/etc/ec2onrails/rails_env", "server/files/etc/ec2onrails/roles.yml", "server/files/etc/environment", "server/files/etc/event.d/god", "server/files/etc/god/db_primary.god", "server/files/etc/god/dkim_filter.god", "server/files/etc/god/
|
16
|
+
s.files = ["CHANGELOG", "COPYING", "ec2onrails.gemspec", "echoe_config.rb", "examples/Capfile", "examples/deploy.rb", "examples/s3.yml", "lib/ec2onrails/capistrano_utils.rb", "lib/ec2onrails/recipes/db.rb", "lib/ec2onrails/recipes/deploy.rb", "lib/ec2onrails/recipes/server.rb", "lib/ec2onrails/recipes.rb", "lib/ec2onrails/version.rb", "lib/ec2onrails.rb", "Manifest", "Rakefile", "README.textile", "server/build", "server/files/etc/aliases", "server/files/etc/cron.d/ec2onrails", "server/files/etc/cron.daily/app", "server/files/etc/cron.daily/logrotate_post", "server/files/etc/cron.hourly/app", "server/files/etc/cron.monthly/app", "server/files/etc/cron.weekly/app", "server/files/etc/default/varnish", "server/files/etc/default/varnishncsa", "server/files/etc/denyhosts.conf", "server/files/etc/dpkg/dpkg.cfg", "server/files/etc/ec2onrails/rails_env", "server/files/etc/ec2onrails/roles.yml", "server/files/etc/environment", "server/files/etc/event.d/god", "server/files/etc/god/db_primary.god", "server/files/etc/god/dkim_filter.god", "server/files/etc/god/master.conf", "server/files/etc/god/memcache.god", "server/files/etc/god/notifications.god", "server/files/etc/god/proxy.god", "server/files/etc/god/system.god", "server/files/etc/god/web.god", "server/files/etc/init.d/ec2-every-startup", "server/files/etc/init.d/ec2-first-startup", "server/files/etc/init.d/nginx", "server/files/etc/logrotate.d/nginx", "server/files/etc/logrotate.d/rails", "server/files/etc/logrotate.d/varnish", "server/files/etc/memcached.conf", "server/files/etc/motd.tail", "server/files/etc/mysql/my.cnf", "server/files/etc/nginx/conf.d/custom.conf", "server/files/etc/nginx/nginx.conf.erb", "server/files/etc/postfix/main.cf", "server/files/etc/README", "server/files/etc/ssh/sshd_config", "server/files/etc/sudoers", "server/files/etc/syslog.conf", "server/files/etc/varnish/default.vcl.erb", "server/files/usr/local/ec2onrails/bin/archive_file", "server/files/usr/local/ec2onrails/bin/backup_app_db", "server/files/usr/local/ec2onrails/bin/backup_dir", "server/files/usr/local/ec2onrails/bin/ec2_meta_data", "server/files/usr/local/ec2onrails/bin/exec_runner", "server/files/usr/local/ec2onrails/bin/in_role", "server/files/usr/local/ec2onrails/bin/init_services", "server/files/usr/local/ec2onrails/bin/install_system_files", "server/files/usr/local/ec2onrails/bin/optimize_mysql", "server/files/usr/local/ec2onrails/bin/public-hostname", "server/files/usr/local/ec2onrails/bin/rails_env", "server/files/usr/local/ec2onrails/bin/rebundle", "server/files/usr/local/ec2onrails/bin/restore_app_db", "server/files/usr/local/ec2onrails/bin/set_rails_env", "server/files/usr/local/ec2onrails/bin/set_roles", "server/files/usr/local/ec2onrails/bin/uninstall_system_files", "server/files/usr/local/ec2onrails/config", "server/files/usr/local/ec2onrails/COPYING", "server/files/usr/local/ec2onrails/lib/aws_helper.rb", "server/files/usr/local/ec2onrails/lib/god_helper.rb", "server/files/usr/local/ec2onrails/lib/mysql_helper.rb", "server/files/usr/local/ec2onrails/lib/roles_helper.rb", "server/files/usr/local/ec2onrails/lib/s3_helper.rb", "server/files/usr/local/ec2onrails/lib/system_files_helper.rb", "server/files/usr/local/ec2onrails/lib/system_files_manifest.rb", "server/files/usr/local/ec2onrails/lib/utils.rb", "server/files/usr/local/ec2onrails/lib/vendor/ini.rb", "server/files/usr/local/ec2onrails/startup-scripts/every-startup/create-mysqld-pid-dir", "server/files/usr/local/ec2onrails/startup-scripts/every-startup/README", "server/files/usr/local/ec2onrails/startup-scripts/first-startup/create-dirs", "server/files/usr/local/ec2onrails/startup-scripts/first-startup/generate-default-web-cert-and-key", "server/files/usr/local/ec2onrails/startup-scripts/first-startup/get-hostname", "server/files/usr/local/ec2onrails/startup-scripts/first-startup/misc", "server/files/usr/local/ec2onrails/startup-scripts/first-startup/prepare-mysql-data-dir", "server/files/usr/local/ec2onrails/startup-scripts/first-startup/README", "server/files/usr/local/ec2onrails/startup-scripts/first-startup/setup-credentials", "server/files/usr/local/ec2onrails/startup-scripts/first-startup/setup-file-permissions", "server/rakefile-wrapper", "server/rakefile.rb", "test/autobench.conf", "test/spec/lib/s3_helper_spec.rb", "test/spec/lib/s3_old.yml", "test/spec/lib/system_files_manifest_spec.rb", "test/spec/test_files/system_files1/_manifest", "test/spec/test_files/system_files1/test1", "test/spec/test_files/system_files1/test2", "test/spec/test_files/system_files1/testfolder/test3", "test/spec/test_files/system_files2/_manifest", "test/spec/test_files/system_files2/test1", "test/spec/test_files/system_files2/test2", "test/spec/test_files/system_files2/testfolder/test3", "test/spec/test_files/test2", "test/test_app/app/controllers/application_controller.rb", "test/test_app/app/controllers/db_fast_controller.rb", "test/test_app/app/controllers/fast_controller.rb", "test/test_app/app/controllers/slow_controller.rb", "test/test_app/app/controllers/very_slow_controller.rb", "test/test_app/app/helpers/application_helper.rb", "test/test_app/Capfile", "test/test_app/config/boot.rb", "test/test_app/config/database.yml", "test/test_app/config/deploy.rb", "test/test_app/config/ec2onrails/config.rb", "test/test_app/config/environment.rb", "test/test_app/config/environments/development.rb", "test/test_app/config/environments/production.rb", "test/test_app/config/environments/test.rb", "test/test_app/config/initializers/backtrace_silencers.rb", "test/test_app/config/initializers/inflections.rb", "test/test_app/config/initializers/mime_types.rb", "test/test_app/config/initializers/new_rails_defaults.rb", "test/test_app/config/initializers/session_store.rb", "test/test_app/config/locales/en.yml", "test/test_app/config/routes.rb", "test/test_app/doc/README_FOR_APP", "test/test_app/public/404.html", "test/test_app/public/422.html", "test/test_app/public/500.html", "test/test_app/public/favicon.ico", "test/test_app/public/images/rails.png", "test/test_app/public/index.html", "test/test_app/public/javascripts/application.js", "test/test_app/public/javascripts/controls.js", "test/test_app/public/javascripts/dragdrop.js", "test/test_app/public/javascripts/effects.js", "test/test_app/public/javascripts/prototype.js", "test/test_app/public/robots.txt", "test/test_app/Rakefile", "test/test_app/README", "test/test_app/script/about", "test/test_app/script/console", "test/test_app/script/dbconsole", "test/test_app/script/destroy", "test/test_app/script/generate", "test/test_app/script/performance/benchmarker", "test/test_app/script/performance/profiler", "test/test_app/script/plugin", "test/test_app/script/runner", "test/test_app/script/server", "test/test_app/test/performance/browsing_test.rb", "test/test_app/test/test_helper.rb", "TODO"]
|
17
17
|
s.homepage = %q{http://ec2onrails.rubyforge.org}
|
18
18
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Ec2onrails", "--main", "README.textile"]
|
19
19
|
s.require_paths = ["lib"]
|
@@ -322,13 +322,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
322
322
|
end
|
323
323
|
|
324
324
|
desc <<-DESC
|
325
|
-
DEPRECATED.
|
326
|
-
RAILS_ROOT/config/ec2onrails/system_files, it can contain files
|
327
|
-
that will be installed into the server relative to "/", and it
|
328
|
-
can contain a manifest file with metadata, this allows the files
|
329
|
-
to be chowned to any user on the system, and it allows the files
|
330
|
-
to be cleanly uninstalled from the system.
|
331
|
-
TODO pointer to full documentation
|
325
|
+
DEPRECATED. See install_system_files.
|
332
326
|
DESC
|
333
327
|
task :deploy_files do
|
334
328
|
if cfg[:server_config_files_root]
|
@@ -352,12 +346,12 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
352
346
|
end
|
353
347
|
|
354
348
|
desc <<-DESC
|
355
|
-
|
356
|
-
RAILS_ROOT/config/ec2onrails/system_files
|
357
|
-
that will be installed into the server relative to "/", and it
|
358
|
-
can contain a manifest file with metadata
|
359
|
-
|
360
|
-
|
349
|
+
Installs files into the system anywhere outside of the Rails app.
|
350
|
+
The directory RAILS_ROOT/config/ec2onrails/system_files can contain
|
351
|
+
files that will be installed into the server relative to "/", and it
|
352
|
+
can contain a manifest file with metadata to change the file owner
|
353
|
+
and permissions, and it allows the files to be cleanly uninstalled
|
354
|
+
from the system.
|
361
355
|
TODO pointer to full documentation
|
362
356
|
DESC
|
363
357
|
task :install_system_files do
|
@@ -434,6 +428,14 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
434
428
|
end
|
435
429
|
end
|
436
430
|
|
431
|
+
desc <<-DESC
|
432
|
+
Clear the varnish proxy cache (if caching is enabled, which it isn't
|
433
|
+
by default). Purges all documents from the cache.
|
434
|
+
DESC
|
435
|
+
task :purge_proxy_cache, :roles => :proxy do
|
436
|
+
run "varnishadm -T localhost:6082 'url.purge .*'"
|
437
|
+
end
|
438
|
+
|
437
439
|
desc <<-DESC
|
438
440
|
Restrict the app user's sudo access.
|
439
441
|
Defaults the user to only be able to \
|
data/lib/ec2onrails/version.rb
CHANGED
@@ -17,3 +17,9 @@ for f in `ls /mnt/log/nginx/*.log` ; do
|
|
17
17
|
/usr/local/ec2onrails/bin/archive_file --file $logfile.gz --dir logs/nginx && rm $logfile.gz
|
18
18
|
fi
|
19
19
|
done
|
20
|
+
|
21
|
+
logfile=/mnt/log/varnish/varnishncsa.log-`date +%Y%m%d`
|
22
|
+
if [ -e $logfile ] ; then
|
23
|
+
gzip $logfile
|
24
|
+
/usr/local/ec2onrails/bin/archive_file --file $logfile.gz --dir logs/varnish && rm $logfile.gz
|
25
|
+
fi
|
@@ -1,5 +1,8 @@
|
|
1
1
|
# For TextMate users, change the language type (at bottom of window, next to line/column counter, to ruby)
|
2
2
|
#
|
3
|
+
|
4
|
+
# TODO move to event-based config
|
5
|
+
|
3
6
|
applog(nil, :info, "loading /etc/god/master.conf")
|
4
7
|
|
5
8
|
require '/usr/local/ec2onrails/lib/god_helper'
|
@@ -15,10 +18,11 @@ APP_ROOT = "/mnt/app/current"
|
|
15
18
|
@configs = GodHelper::Configs.new
|
16
19
|
|
17
20
|
God.pid_file_directory = "/var/run/god"
|
18
|
-
God.load "/etc/god/*.god"
|
19
21
|
|
20
|
-
applog(nil, :info, "
|
22
|
+
applog(nil, :info, "About to load system configs at /etc/god/*.god")
|
23
|
+
God.load "/etc/god/*.god"
|
21
24
|
|
25
|
+
applog(nil, :info, "About to load application-specific configs at #{APP_ROOT}/config/god/*.god")
|
22
26
|
God.load "#{APP_ROOT}/config/god/*.god"
|
23
27
|
|
24
28
|
|
@@ -2,13 +2,10 @@ God::Contacts::Email.message_settings = {
|
|
2
2
|
:from => 'root@localhost'
|
3
3
|
}
|
4
4
|
|
5
|
-
God::Contacts::Email.
|
6
|
-
:address => 'localhost',
|
7
|
-
:port => 25
|
8
|
-
}
|
5
|
+
God::Contacts::Email.delivery_method = :sendmail
|
9
6
|
|
10
7
|
God.contact(:email) do |c|
|
11
|
-
c.name = '
|
8
|
+
c.name = 'root'
|
12
9
|
c.email = 'root@localhost'
|
13
10
|
c.group = 'default'
|
14
11
|
end
|
@@ -21,6 +21,20 @@ God.watch do |w|
|
|
21
21
|
# the moment we don't have much swap configured (just using the defaults
|
22
22
|
# from Eric Hammond's base image).
|
23
23
|
restart_if_resource_hog(w, :memory_usage => 100.megabytes, :cpu_usage => 50.percent)
|
24
|
-
|
25
|
-
|
24
|
+
end
|
25
|
+
|
26
|
+
God.watch do |w|
|
27
|
+
w.name = "varnishncsa"
|
28
|
+
w.group = "proxy"
|
29
|
+
w.autostart = false
|
30
|
+
|
31
|
+
w.start = "/etc/init.d/varnishncsa start"
|
32
|
+
w.stop = "/etc/init.d/varnishncsa stop"
|
33
|
+
w.restart = "/etc/init.d/varnishncsa restart"
|
34
|
+
w.pid_file = "/var/run/varnishncsa.pid"
|
35
|
+
w.grace = 10.seconds
|
36
|
+
|
37
|
+
default_configurations(w)
|
38
|
+
|
39
|
+
restart_if_resource_hog(w, :memory_usage => 100.megabytes, :cpu_usage => 50.percent)
|
26
40
|
end
|
@@ -12,23 +12,26 @@ God.watch do |w|
|
|
12
12
|
on.condition(:disk_usage) do |c|
|
13
13
|
c.mount_point = "/"
|
14
14
|
c.above = 75
|
15
|
+
c.notify = {:contacts => ['default'], :category => "RAILS_ENV=#{Ec2onrails::Utils.rails_env}"}
|
15
16
|
end
|
16
17
|
|
17
18
|
on.condition(:disk_usage) do |c|
|
18
19
|
c.mount_point = "/mnt"
|
19
20
|
c.above = 75
|
21
|
+
c.notify = {:contacts => ['default'], :category => "RAILS_ENV=#{Ec2onrails::Utils.rails_env}"}
|
20
22
|
end
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
on.condition(:memory_usage) do |c|
|
25
|
+
c.above = 80.percent
|
26
|
+
c.times = [3, 5] # 3 out of 5 intervals
|
27
|
+
c.notify = {:contacts => ['default'], :category => "RAILS_ENV=#{Ec2onrails::Utils.rails_env}"}
|
28
|
+
end
|
26
29
|
|
27
30
|
on.condition(:cpu_usage) do |c|
|
28
31
|
c.above = 90.percent
|
29
32
|
c.times = [5, 8]
|
30
|
-
|
31
|
-
|
33
|
+
c.notify = {:contacts => ['default'], :category => "RAILS_ENV=#{Ec2onrails::Utils.rails_env}"}
|
34
|
+
end
|
32
35
|
end
|
33
36
|
|
34
37
|
end
|
@@ -1,11 +1,10 @@
|
|
1
1
|
/mnt/log/nginx/*.log {
|
2
2
|
daily
|
3
|
+
rotate 7
|
3
4
|
missingok
|
4
5
|
dateext
|
5
|
-
compress
|
6
|
-
create 640 root app
|
7
|
-
notifempty
|
8
6
|
sharedscripts
|
9
|
-
|
10
|
-
|
7
|
+
postrotate
|
8
|
+
test -f /var/run/nginx.pid && kill -USR1 `cat /var/run/nginx.pid`
|
9
|
+
endscript
|
11
10
|
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
/mnt/log/varnish/varnish.log /mnt/log/varnish/varnishncsa.log {
|
2
|
+
daily
|
3
|
+
rotate 7
|
4
|
+
missingok
|
5
|
+
dateext
|
6
|
+
sharedscripts
|
7
|
+
postrotate
|
8
|
+
for service in varnishlog varnishncsa; do
|
9
|
+
if /usr/bin/pgrep -P 1 $service >/dev/null; then
|
10
|
+
/usr/sbin/invoke-rc.d $service reload > /dev/null
|
11
|
+
fi
|
12
|
+
done
|
13
|
+
endscript
|
14
|
+
}
|
@@ -12,13 +12,17 @@ http {
|
|
12
12
|
passenger_root <%= `/usr/bin/passenger-config --root`.strip %>;
|
13
13
|
passenger_default_user app;
|
14
14
|
passenger_pool_idle_time 0;
|
15
|
-
rails_spawn_method conservative;
|
16
15
|
rails_framework_spawner_idle_time 0;
|
17
16
|
rails_app_spawner_idle_time 0;
|
17
|
+
|
18
18
|
# We leave passenger_max_pool_size at the default for now. (It might
|
19
19
|
# eventually be an ERB variable that can be set automatically based on the
|
20
20
|
# instance type and what roles it's in.)
|
21
21
|
# passenger_max_pool_size 6;
|
22
|
+
|
23
|
+
# We leave the rails_spawn_method at the default, but we might want a config setting
|
24
|
+
# to allow it to be changed.
|
25
|
+
# rails_spawn_method smart-lv2;
|
22
26
|
|
23
27
|
include /etc/nginx/mime.types;
|
24
28
|
|
@@ -88,7 +92,7 @@ http {
|
|
88
92
|
root /mnt/app/current/public;
|
89
93
|
|
90
94
|
error_page 400 /400.html;
|
91
|
-
error_page 500 502
|
95
|
+
error_page 500 502 504 /500.html;
|
92
96
|
location = /500.html {
|
93
97
|
root /mnt/app/current/public;
|
94
98
|
}
|
@@ -110,9 +114,14 @@ http {
|
|
110
114
|
# page if it exists in the doc root. This is for capistrano's
|
111
115
|
# disable web task
|
112
116
|
if (-f $document_root/system/maintenance.html) {
|
117
|
+
return 503;
|
118
|
+
}
|
119
|
+
error_page 503 @503;
|
120
|
+
location @503 {
|
113
121
|
rewrite ^(.*)$ /system/maintenance.html break;
|
114
122
|
}
|
115
123
|
|
124
|
+
|
116
125
|
# see http://wiki.codemongers.com/NginxHttpStubStatusModule
|
117
126
|
# for more information
|
118
127
|
location /nginx_status {
|
@@ -29,7 +29,7 @@ RAILS_ENV = Ec2onrails::Utils.rails_env
|
|
29
29
|
|
30
30
|
#reload configs to pick up any new changes
|
31
31
|
# Just a thought... do we really need to load god files from inside the app? They could just be installed via install_system_files, that would be simpler
|
32
|
-
Dir.glob("/etc/god/*.god") + Dir.glob("/mnt/app/current/config/god
|
32
|
+
Dir.glob("/etc/god/*.god") + Dir.glob("/mnt/app/current/config/god/*.god").each do |f|
|
33
33
|
sudo "god load '#{f}'"
|
34
34
|
end
|
35
35
|
|
@@ -12,7 +12,7 @@ fi
|
|
12
12
|
export EC2_HOME=/usr/local/ec2-api-tools
|
13
13
|
export PATH="$PATH:$EC2_HOME/bin"
|
14
14
|
|
15
|
-
export JAVA_HOME="/usr/lib/jvm/java-6-sun"
|
15
|
+
if [ -e "/usr/lib/jvm/java-6-sun" ]; then export JAVA_HOME="/usr/lib/jvm/java-6-sun"; fi
|
16
16
|
|
17
17
|
# Set the bash prompt to include the rails environment name
|
18
18
|
case "$TERM" in
|
@@ -1,5 +1,6 @@
|
|
1
1
|
module GodHelper
|
2
2
|
require '/usr/local/ec2onrails/lib/roles_helper'
|
3
|
+
require '/usr/local/ec2onrails/lib/utils'
|
3
4
|
require 'fileutils'
|
4
5
|
|
5
6
|
def default_configurations(w)
|
@@ -11,32 +12,45 @@ module GodHelper
|
|
11
12
|
|
12
13
|
w.start_if do |start|
|
13
14
|
start.condition(:process_running) do |c|
|
14
|
-
c.notify = {:contacts => ['default'], :category => 'process not started...starting'}
|
15
15
|
c.interval = 5.seconds
|
16
16
|
c.running = false
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
# determine when process has finished starting
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
#
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
21
|
+
w.transition([:start, :restart], :up) do |on|
|
22
|
+
on.condition(:process_running) do |c|
|
23
|
+
c.running = true
|
24
|
+
end
|
25
|
+
|
26
|
+
# failsafe
|
27
|
+
on.condition(:tries) do |c|
|
28
|
+
c.times = 8
|
29
|
+
c.within = 2.minutes
|
30
|
+
c.transition = :start
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# start if process is not running
|
35
|
+
w.transition(:up, :start) do |on|
|
36
|
+
on.condition(:process_exits) do |c|
|
37
|
+
c.notify = {:contacts => ['default'], :category => "RAILS_ENV=#{Ec2onrails::Utils.rails_env}"}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
w.lifecycle do |on|
|
42
|
+
on.condition(:flapping) do |c|
|
43
|
+
c.notify = {:contacts => ['default'], :category => "RAILS_ENV=#{Ec2onrails::Utils.rails_env}"}
|
44
|
+
c.to_state = [:start, :restart]
|
45
|
+
c.times = 5
|
46
|
+
c.within = 5.minutes
|
47
|
+
c.transition = :unmonitored
|
48
|
+
c.retry_in = 10.minutes
|
49
|
+
c.retry_times = 5
|
50
|
+
c.retry_within = 2.hours
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
40
54
|
end
|
41
55
|
|
42
56
|
def restart_if_resource_hog(w, options={})
|
@@ -44,7 +58,7 @@ module GodHelper
|
|
44
58
|
w.restart_if do |restart|
|
45
59
|
if options[:memory_usage]
|
46
60
|
restart.condition(:memory_usage) do |c|
|
47
|
-
c.notify = {:contacts => ['default'], :category => "
|
61
|
+
c.notify = {:contacts => ['default'], :category => "RAILS_ENV=#{Ec2onrails::Utils.rails_env}"}
|
48
62
|
c.above = options[:memory_usage]
|
49
63
|
c.times = [3,5]
|
50
64
|
end
|
@@ -52,7 +66,7 @@ module GodHelper
|
|
52
66
|
|
53
67
|
if options[:cpu_usage]
|
54
68
|
restart.condition(:cpu_usage) do |c|
|
55
|
-
c.notify = {:contacts => ['default'], :category => "
|
69
|
+
c.notify = {:contacts => ['default'], :category => "RAILS_ENV=#{Ec2onrails::Utils.rails_env}"}
|
56
70
|
c.above = options[:cpu_usage]
|
57
71
|
c.times = 5
|
58
72
|
end
|
@@ -63,24 +77,8 @@ module GodHelper
|
|
63
77
|
end
|
64
78
|
end
|
65
79
|
|
66
|
-
def monitor_lifecycle(w)
|
67
|
-
# w.transition(:up, :unmonitored) do |on|
|
68
|
-
w.lifecycle do |on|
|
69
|
-
on.condition(:flapping) do |c|
|
70
|
-
c.notify = {:contacts => ['default'], :category => 'process flapping...restarting'}
|
71
|
-
c.to_state = [:start, :restart]
|
72
|
-
c.times = 5
|
73
|
-
c.within = 5.minutes
|
74
|
-
c.transition = :unmonitored
|
75
|
-
c.retry_in = 10.minutes
|
76
|
-
c.retry_times = 5
|
77
|
-
c.retry_within = 2.hours
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
80
|
class Configs
|
83
81
|
include Ec2onrails::RolesHelper
|
84
82
|
end
|
85
83
|
|
86
|
-
end
|
84
|
+
end
|
data/server/rakefile.rb
CHANGED
@@ -87,7 +87,7 @@ require "#{File.dirname(__FILE__)}/../lib/ec2onrails/version"
|
|
87
87
|
"optiflag",
|
88
88
|
"passenger",
|
89
89
|
"rails",
|
90
|
-
"rails -v '~> 2.3.
|
90
|
+
"rails -v '~> 2.3.3'",
|
91
91
|
"rails -v '~> 2.2.2'",
|
92
92
|
"rails -v '~> 2.1.2'",
|
93
93
|
"rails -v '~> 2.0.5'",
|
@@ -134,11 +134,13 @@ end
|
|
134
134
|
desc "Install required ruby gems inside the image's filesystem"
|
135
135
|
task :install_gems => [:require_root, :install_packages] do |t|
|
136
136
|
unless_completed(t) do
|
137
|
-
|
138
|
-
|
137
|
+
version = "1.3.5"
|
138
|
+
dir = "60718"
|
139
139
|
|
140
|
+
filename = "rubygems-#{version}.tgz"
|
141
|
+
url = "http://rubyforge.org/frs/download.php/#{dir}/#{filename}"
|
140
142
|
run_chroot "sh -c 'cd /tmp && wget -q #{url} && tar zxf #{filename}'"
|
141
|
-
run_chroot "sh -c 'cd /tmp/rubygems
|
143
|
+
run_chroot "sh -c 'cd /tmp/rubygems-#{version} && ruby setup.rb'"
|
142
144
|
run_chroot "ln -sf /usr/bin/gem1.8 /usr/bin/gem"
|
143
145
|
#NOTE: this will update to the most recent rubygems version even if we haven't updated the url here
|
144
146
|
run_chroot "gem update --system --no-rdoc --no-ri"
|
@@ -204,7 +206,7 @@ task :configure => [:require_root, :install_software] do |t|
|
|
204
206
|
run_chroot "update-rc.d ec2-every-startup start 92 S ."
|
205
207
|
|
206
208
|
# Disable the services that will be managed by god, depending on the roles
|
207
|
-
%w(nginx mysql memcached varnish).each do |service|
|
209
|
+
%w(nginx mysql memcached varnish varnishncsa).each do |service|
|
208
210
|
run_chroot "update-rc.d -f #{service} remove"
|
209
211
|
run_chroot "update-rc.d #{service} stop 20 2 3 4 5 ."
|
210
212
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pauldowman-ec2onrails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.10.
|
4
|
+
version: 0.9.10.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Dowman, Adam Greene
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-08-06 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -71,6 +71,7 @@ extra_rdoc_files:
|
|
71
71
|
files:
|
72
72
|
- CHANGELOG
|
73
73
|
- COPYING
|
74
|
+
- ec2onrails.gemspec
|
74
75
|
- echoe_config.rb
|
75
76
|
- examples/Capfile
|
76
77
|
- examples/deploy.rb
|
@@ -103,7 +104,6 @@ files:
|
|
103
104
|
- server/files/etc/event.d/god
|
104
105
|
- server/files/etc/god/db_primary.god
|
105
106
|
- server/files/etc/god/dkim_filter.god
|
106
|
-
- server/files/etc/god/examples/have_god_daemonize.god
|
107
107
|
- server/files/etc/god/master.conf
|
108
108
|
- server/files/etc/god/memcache.god
|
109
109
|
- server/files/etc/god/notifications.god
|
@@ -113,8 +113,9 @@ files:
|
|
113
113
|
- server/files/etc/init.d/ec2-every-startup
|
114
114
|
- server/files/etc/init.d/ec2-first-startup
|
115
115
|
- server/files/etc/init.d/nginx
|
116
|
-
- server/files/etc/logrotate.d/mongrel
|
117
116
|
- server/files/etc/logrotate.d/nginx
|
117
|
+
- server/files/etc/logrotate.d/rails
|
118
|
+
- server/files/etc/logrotate.d/varnish
|
118
119
|
- server/files/etc/memcached.conf
|
119
120
|
- server/files/etc/motd.tail
|
120
121
|
- server/files/etc/mysql/my.cnf
|
@@ -228,9 +229,9 @@ files:
|
|
228
229
|
- test/test_app/test/performance/browsing_test.rb
|
229
230
|
- test/test_app/test/test_helper.rb
|
230
231
|
- TODO
|
231
|
-
- ec2onrails.gemspec
|
232
232
|
has_rdoc: false
|
233
233
|
homepage: http://ec2onrails.rubyforge.org
|
234
|
+
licenses:
|
234
235
|
post_install_message:
|
235
236
|
rdoc_options:
|
236
237
|
- --line-numbers
|
@@ -256,7 +257,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
256
257
|
requirements: []
|
257
258
|
|
258
259
|
rubyforge_project: ec2onrails
|
259
|
-
rubygems_version: 1.
|
260
|
+
rubygems_version: 1.3.5
|
260
261
|
signing_key:
|
261
262
|
specification_version: 3
|
262
263
|
summary: Client-side libraries (Capistrano tasks) for managing and deploying to EC2 on Rails servers.
|
@@ -1,18 +0,0 @@
|
|
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
|