mikejones-rubybroker-ec2 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,37 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+ namespace :deploy do
3
+ desc "Restart Application"
4
+ task :restart, :roles => :app do
5
+ run "touch #{current_path}/tmp/restart.txt"
6
+ end
7
+
8
+ desc "Start have been overwritten to restart apache"
9
+ task :start, :roles => :app do
10
+ run "apache2ctl graceful"
11
+ end
12
+
13
+ desc <<-DESC
14
+ A slightly change version of the migrate script so it users MERB_ENV to migrate
15
+
16
+ set :rake, "rake"
17
+ set :merb_env, "production"
18
+ set :migrate_env, ""
19
+ set :migrate_target, :latest
20
+ DESC
21
+ task :migrate, :roles => :db, :only => { :primary => true } do
22
+ rake = fetch(:rake, "rake")
23
+ merb_env = fetch(:merb_env, "production")
24
+ migrate_env = fetch(:migrate_env, "")
25
+ migrate_target = fetch(:migrate_target, :latest)
26
+
27
+ directory = case migrate_target.to_sym
28
+ when :current then current_path
29
+ when :latest then current_release
30
+ else raise ArgumentError, "unknown migration target #{migrate_target.inspect}"
31
+ end
32
+
33
+ run "cd #{directory}; #{rake} MERB_ENV=#{merb_env} #{migrate_env} db:migrate"
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1,106 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+ namespace :instance do
3
+ desc "Start an instance"
4
+ task :start do
5
+ system "ec2-run-instances #{image_id} -k #{keypair}"
6
+ end
7
+
8
+ task :describe do
9
+ system "ec2-describe-instances #{instance_id}"
10
+ end
11
+
12
+ desc "Stop running instance"
13
+ task :stop do
14
+ system "ec2-terminate-instances #{instance_id}"
15
+ end
16
+
17
+ desc "SSH to running instance"
18
+ task :ssh do
19
+ system "ssh -i #{keypair_full_path} #{username}@#{instance_url}"
20
+ end
21
+
22
+ desc "Install and configure apache2 and passenger"
23
+ task :bootstrap do
24
+ install_apache
25
+ install_passenger
26
+ install_mysql
27
+ install_git
28
+ install_merb
29
+ install_missing_gems
30
+ setup_virtual_host
31
+ end
32
+
33
+ task :install_merb do
34
+ if merb_version == "0.9.5"
35
+ install_libxml
36
+ install_memcacheclient
37
+ end
38
+ run "gem install merb -v #{merb_version} --no-ri --no-rdoc"
39
+ end
40
+
41
+ task :install_memcacheclient do
42
+ run "gem install memcache-client --no-ri --no-rdoc"
43
+ end
44
+
45
+ task :install_libxml do
46
+ run <<-CMD
47
+ apt-get install libxml2-dev -y &&
48
+ gem install libxml-ruby --no-ri --no-rdoc
49
+ CMD
50
+ end
51
+
52
+ task :install_missing_gems do
53
+ run "gem install rubigen --no-ri --no-rdoc"
54
+ end
55
+
56
+ task :install_apache do
57
+ run <<-CMD
58
+ apt-get install apache2 -y &&
59
+ apt-get install apache2-prefork-dev -y
60
+ CMD
61
+ end
62
+
63
+ task :install_passenger do
64
+ run <<-CMD
65
+ gem install passenger --no-ri --no-rdoc &&
66
+ cd /usr/lib/ruby/gems/1.8/gems/passenger-2.0.3 &&
67
+ rake clean apache2 &&
68
+ echo "#phusion passenger" >> /etc/apache2/apache2.conf &&
69
+ echo "LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.0.3/ext/apache2/mod_passenger.so" >> /etc/apache2/apache2.conf &&
70
+ echo "PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.0.3" >> /etc/apache2/apache2.conf &&
71
+ echo "PassengerRuby /usr/bin/ruby1.8" >> apache2.conf
72
+ CMD
73
+ # /etc/init.d/apache2 restart
74
+ end
75
+
76
+ task :install_mysql do
77
+ run "apt-get install mysql-server -y"
78
+ end
79
+
80
+ task :install_git do
81
+ run <<-CMD
82
+ wget http://www.kernel.org/pub/software/scm/git/git-1.5.6.tar.gz &&
83
+ tar -xzf git-1.5.6.tar.gz &&
84
+ rm git-1.5.6.tar.gz &&
85
+ cd git-1.5.6 &&
86
+ ./configure &&
87
+ make &&
88
+ make install
89
+ CMD
90
+ end
91
+
92
+ task :setup_virtual_host do
93
+ run <<-CMD
94
+
95
+ echo "127.0.0.1 localhost #{instance_url}" >> /etc/hosts &&
96
+ echo "<VirtualHost *>" >> /etc/apache2/sites-available/#{application} &&
97
+ echo " ServerName #{instance_url}" >> /etc/apache2/sites-available/#{application} &&
98
+ echo " DocumentRoot #{deploy_to}/current/public" >> /etc/apache2/sites-available/#{application} &&
99
+ echo " ErrorLog #{deploy_to}/current/log/error.log" >> /etc/apache2/sites-available/#{application} &&
100
+ echo "</VirtualHost>" >> /etc/apache2/sites-available/#{application} &&
101
+ cd /etc/apache2/sites-available &&
102
+ a2ensite #{application}
103
+ CMD
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,15 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+ namespace :passenger do
3
+ desc "Analyze Phusion Passenger's and Apache's real memory usage."
4
+ task :memory_stats, :roles => :app do
5
+ run "passenger-memory-stats"
6
+ end
7
+
8
+ desc "Inspect Phusion Passenger's internal status"
9
+ task :status, :roles => :app do
10
+ run "passenger-status"
11
+ end
12
+
13
+ end
14
+ end
15
+
@@ -0,0 +1,12 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+ set :merb_version, "0.9.5"
3
+ set :image_id, "ami-bded09d4"
4
+ set :deploy_to, "/mnt/apps/#{application}"
5
+ set :username, "root"
6
+ set :use_sudo, false # because we are using debian etch
7
+
8
+ set :keypair_full_path, "#{ENV['HOME']}/.ec2/id_rsa-#{keypair}"
9
+ ssh_options[:username] = username
10
+ ssh_options[:keys] = keypair_full_path
11
+ default_run_options[:pty] = true
12
+ end
@@ -0,0 +1 @@
1
+ Dir[File.dirname(__FILE__) + "/recipes/*"].each { |r| require r }
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mikejones-rubybroker-ec2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Michael Jones
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-08-24 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Capistrano gumph for easy deployment of you merb app to ec2.
17
+ email: michael.daniel.jones@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - lib/rubybroker-ec2.rb
26
+ - lib/recipes/settings.rb
27
+ - lib/recipes/ec2.rb
28
+ - lib/recipes/deploy.rb
29
+ - lib/recipes/passenger.rb
30
+ has_rdoc: false
31
+ homepage: http://neophiliac.net/rubybroker-ec2
32
+ post_install_message:
33
+ rdoc_options: []
34
+
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: "0"
42
+ version:
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: "0"
48
+ version:
49
+ requirements: []
50
+
51
+ rubyforge_project:
52
+ rubygems_version: 1.2.0
53
+ signing_key:
54
+ specification_version: 2
55
+ summary: Easy deployment for Merb applications.
56
+ test_files: []
57
+