yyyc514-dwell 0.1.99
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +19 -0
- data/README.txt +37 -0
- data/bin/dwell +3 -0
- data/lib/dwell/cap_extensions.rb +118 -0
- data/lib/dwell/known_hosts/github +1 -0
- data/lib/dwell/recipes/apache.rb +107 -0
- data/lib/dwell/recipes/bootstrap/linode.rb +75 -0
- data/lib/dwell/recipes/campfire.rb +55 -0
- data/lib/dwell/recipes/extras/daemontools.rb +57 -0
- data/lib/dwell/recipes/extras/php.rb +3 -0
- data/lib/dwell/recipes/extras/tinydns.rb +61 -0
- data/lib/dwell/recipes/gems.rb +33 -0
- data/lib/dwell/recipes/git.rb +25 -0
- data/lib/dwell/recipes/imagemagick.rb +26 -0
- data/lib/dwell/recipes/mercurial.rb +13 -0
- data/lib/dwell/recipes/mysql/base.rb +35 -0
- data/lib/dwell/recipes/mysql/db.rb +70 -0
- data/lib/dwell/recipes/mysql/helper.rb +19 -0
- data/lib/dwell/recipes/mysql.rb +4 -0
- data/lib/dwell/recipes/passenger.rb +45 -0
- data/lib/dwell/recipes/rails/app.rb +74 -0
- data/lib/dwell/recipes/rails/base.rb +91 -0
- data/lib/dwell/recipes/rails_app.rb +1 -0
- data/lib/dwell/recipes/ruby.rb +23 -0
- data/lib/dwell/recipes/sqlite.rb +14 -0
- data/lib/dwell/recipes/svn.rb +13 -0
- data/lib/dwell/recipes/ubuntu.rb +45 -0
- data/lib/dwell/recipes.rb +33 -0
- data/lib/dwell/templates/deploy.rb +47 -0
- data/lib/dwell/templates/passenger.conf +8 -0
- data/lib/dwell/templates/vhost.conf +48 -0
- data/lib/dwell/templates/vhost_ssl.conf +69 -0
- data/lib/dwell/ubuntu_extensions.rb +18 -0
- data/lib/dwell.rb +9 -0
- metadata +103 -0
@@ -0,0 +1,70 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
namespace :dwell do
|
3
|
+
namespace :mysql do
|
4
|
+
|
5
|
+
# database operations
|
6
|
+
# TODO: should this be dwell:app:db namespace or something?
|
7
|
+
namespace :db do
|
8
|
+
|
9
|
+
desc "Create MySQL database and user based on config/database.yml"
|
10
|
+
task :create, :roles => :db, :only => { :primary => true } do
|
11
|
+
|
12
|
+
set_mysql_admin
|
13
|
+
read_config
|
14
|
+
|
15
|
+
sql = "CREATE DATABASE #{db_name};"
|
16
|
+
sql += "GRANT ALL PRIVILEGES ON #{db_name}.* TO #{db_user}@localhost IDENTIFIED BY '#{db_password}';"
|
17
|
+
mysql_helper.execute sql, mysql_admin
|
18
|
+
end
|
19
|
+
|
20
|
+
def set_mysql_admin
|
21
|
+
set :mysql_admin, user unless mysql_admin
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "dump database"
|
25
|
+
task :dump, :roles => :db, :only => { :primary => true } do
|
26
|
+
read_config
|
27
|
+
run "cd #{deploy_to} && mysqldump --add-drop-table #{db_name } -u#{db_user} -p#{db_password} > dump_#{short_date}.sql"
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "fetch dumped database"
|
31
|
+
task :fetch, :roles => :db, :only => { :primary => true } do
|
32
|
+
run "gzip #{deploy_to}/dump_#{short_date}.sql"
|
33
|
+
get "#{deploy_to}/dump_#{short_date}.sql.gz", "dump_#{short_date}.sql.gz"
|
34
|
+
`gunzip dump_#{short_date}.sql.gz`
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "push the local dump to the remote"
|
38
|
+
task :push, :roles => :db, :only => { :primary => true } do
|
39
|
+
`gzip dump_#{short_date}.sql`
|
40
|
+
upload "dump_#{short_date}.sql.gz", "#{deploy_to}/dump_#{short_date}.sql.gz"
|
41
|
+
run "gunzip #{deploy_to}/dump_#{short_date}.sql.gz"
|
42
|
+
end
|
43
|
+
|
44
|
+
desc "import the database into the remote"
|
45
|
+
task :import, :roles => :db, :only => { :primary => true } do
|
46
|
+
read_config
|
47
|
+
run "mysql #{db_name} -u#{db_user} -p#{db_password} < #{deploy_to}/dump_#{short_date}.sql"
|
48
|
+
end
|
49
|
+
|
50
|
+
task :dump_and_fetch, :roles => :db, :only => { :primary => true } do
|
51
|
+
dump
|
52
|
+
fetch
|
53
|
+
end
|
54
|
+
|
55
|
+
def short_date
|
56
|
+
Date.today.strftime("%m-%d-%y")
|
57
|
+
end
|
58
|
+
|
59
|
+
def read_config
|
60
|
+
db_config = YAML.load_file('config/database.yml')
|
61
|
+
set :db_user, db_config[rails_env]["username"]
|
62
|
+
set :db_password, db_config[rails_env]["password"]
|
63
|
+
set :db_name, db_config[rails_env]["database"]
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module MySQLMethods
|
2
|
+
|
3
|
+
def execute(sql, user)
|
4
|
+
run "mysql --user=#{user} -p --execute=\"#{sql}\"" do |channel, stream, data|
|
5
|
+
handle_mysql_password(user, channel, stream, data)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
def handle_mysql_password(user, channel, stream, data)
|
11
|
+
logger.info data, "[database on #{channel[:host]} asked for password]"
|
12
|
+
if data =~ /^Enter password:/
|
13
|
+
pass = Capistrano::CLI.password_prompt "Enter database password for '#{user}':"
|
14
|
+
channel.send_data "#{pass}\n"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
Capistrano.plugin :mysql_helper, MySQLMethods
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'erb'
|
2
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
3
|
+
namespace :dwell do
|
4
|
+
namespace :passenger do
|
5
|
+
|
6
|
+
set :passenger_use_global_queue, "off"
|
7
|
+
set :passenger_pool_idle_time, 300
|
8
|
+
set :passenger_rails_spawn_method, "smart"
|
9
|
+
set :passenger_max_instances_per_app, 0
|
10
|
+
set :passenger_max_pool_size, 6
|
11
|
+
set :passenger_ruby, "/usr/bin/ruby1.8"
|
12
|
+
|
13
|
+
desc "Install Passenger Apache 2 module"
|
14
|
+
task :install_passenger_module do
|
15
|
+
dwell1.sudo_with_input "passenger-install-apache2-module", /enter/i, "\n"
|
16
|
+
dwell1.record_install "apache2_mod_passenger"
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "Setup the configuration for mod_massenger"
|
20
|
+
task :setup do
|
21
|
+
set :passenger_ruby, "/opt/ruby-enterprise/bin/ruby" if which_ruby==:enterprise
|
22
|
+
run "gem list --local | grep passenger" do |channel, stream, data|
|
23
|
+
if data.match(/passenger \(([^ ,)]*)/)
|
24
|
+
set :passenger_version, $1
|
25
|
+
else
|
26
|
+
raise "couldn't determine version of passenger gem"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
file = File.join(File.dirname(__FILE__), "../templates", "passenger.conf")
|
30
|
+
template = File.read(file)
|
31
|
+
buffer = ERB.new(template).result(binding)
|
32
|
+
put buffer, "/tmp/passenger"
|
33
|
+
puts buffer
|
34
|
+
sudo "mv /tmp/passenger /etc/apache2/conf.d/passenger"
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "Install Passenger"
|
38
|
+
task :install do
|
39
|
+
install_passenger_module
|
40
|
+
setup
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
|
3
|
+
# do this so we can use this method inside the app namespace below
|
4
|
+
# as we can't use this method while we're still defining the namespace
|
5
|
+
namespace :app do
|
6
|
+
def railsmachine_gem?
|
7
|
+
top.respond_to?(:apache) and top.apache.respond_to?(:set_apache_conf)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
namespace :app do
|
12
|
+
|
13
|
+
# lets not overwrite rails machine - try and be compatible
|
14
|
+
unless top.app.railsmachine_gem?
|
15
|
+
|
16
|
+
namespace :db do
|
17
|
+
desc "setup the database automatically"
|
18
|
+
task :setup do
|
19
|
+
top.dwell.mysql.db.create
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
namespace :web do
|
24
|
+
desc "setup a passenger config for this app"
|
25
|
+
task :setup do
|
26
|
+
top.dwell.apache.copy_certs
|
27
|
+
top.dwell.apache.site.setup
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
namespace :deploy do
|
35
|
+
|
36
|
+
set :known_hosts, []
|
37
|
+
|
38
|
+
after "deploy:setup" do
|
39
|
+
fix_permissions
|
40
|
+
top.dwell.rails.setup_deploy_keys
|
41
|
+
end
|
42
|
+
|
43
|
+
task :fix_permissions do
|
44
|
+
sudo "chown -R #{user}:admin #{deploy_to}"
|
45
|
+
end
|
46
|
+
|
47
|
+
# lets not overwrite rails machine - try and be compatible
|
48
|
+
unless top.app.railsmachine_gem?
|
49
|
+
|
50
|
+
desc "restart your rails app"
|
51
|
+
task :restart do
|
52
|
+
run "touch #{current_path}/tmp/restart.txt"
|
53
|
+
end
|
54
|
+
|
55
|
+
[:start, :stop].each do |t|
|
56
|
+
desc "The :#{t} task has no effect when using Passenger as your application server."
|
57
|
+
task t, :roles => :app do
|
58
|
+
puts "The :#{t} task has no effect when using Passenger as your application server."
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# pulled from Capistrano and enhanced with gem installs
|
63
|
+
desc "cold app deploy that does gem installs as well"
|
64
|
+
task :cold do
|
65
|
+
update
|
66
|
+
top.dwell.rails.install_app_gems
|
67
|
+
migrate
|
68
|
+
top.dwell.apache.reload
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
|
3
|
+
before 'deploy:update_code', 'dwell:rails:symlinks:setup'
|
4
|
+
after 'deploy:symlink', 'dwell:rails:symlinks:update'
|
5
|
+
after :deploy,'deploy:cleanup'
|
6
|
+
|
7
|
+
namespace :dwell do
|
8
|
+
namespace :rails do
|
9
|
+
|
10
|
+
desc "fully setup the application and cold deploy it"
|
11
|
+
task :setup_and_deploy_cold do
|
12
|
+
top.deploy.setup
|
13
|
+
top.app.db.setup
|
14
|
+
top.app.web.setup
|
15
|
+
top.deploy.cold
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "install the gems specified with config.gem"
|
19
|
+
task :install_app_gems do
|
20
|
+
run "grep '^[^#]*config.gem' #{current_path}/config/environment.rb && " +
|
21
|
+
"cd #{current_path} && #{sudo} rake gems:install"
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "copy deploy keys (public and private) to the server and setup known_hosts"
|
25
|
+
task :setup_deploy_keys do
|
26
|
+
if File.exist?("config/dwell/deploy_keys/#{user}")
|
27
|
+
put File.read("config/dwell/deploy_keys/#{user}"), "/home/#{user}/.ssh/id_rsa", :mode => 0600
|
28
|
+
sudo "chown #{user}.admin /home/#{user}/.ssh/id_rsa"
|
29
|
+
put File.read("config/dwell/deploy_keys/#{user}.pub"), "/home/#{user}/.ssh/id_rsa.pub", :mode => 0600
|
30
|
+
sudo "chown #{user}.admin /home/#{user}/.ssh/id_rsa.pub"
|
31
|
+
end
|
32
|
+
known_hosts.each do |host|
|
33
|
+
key=File.open("#{File.dirname(__FILE__)}/../known_hosts/#{host}").read
|
34
|
+
dwell1.append_to_file_if_missing("/home/#{user}/.ssh/known_hosts", key)
|
35
|
+
end
|
36
|
+
sudo "chown #{user}.admin /home/#{user}/.ssh/known_hosts"
|
37
|
+
end
|
38
|
+
|
39
|
+
namespace :shared do
|
40
|
+
desc "dump shared file to archive"
|
41
|
+
task :archive, :roles => :app, :only => { :primary => true } do
|
42
|
+
to_backup=[]
|
43
|
+
app_symlinks.map do |key, value|
|
44
|
+
dir=(key==:root) ? value : key
|
45
|
+
to_backup << "shared/" + dir
|
46
|
+
end
|
47
|
+
run "cd #{deploy_to} && tar -czf shared.tar.gz #{to_backup.join " "}"
|
48
|
+
end
|
49
|
+
|
50
|
+
desc "fetch shared files locally"
|
51
|
+
task :fetch, :roles => :app, :only => { :primary => true } do
|
52
|
+
get "#{deploy_to}/shared.tar.gz", "shared.tar.gz"
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "push shared archive to the remote"
|
56
|
+
task :push, :roles => :app, :only => { :primary => true } do
|
57
|
+
upload "shared.tar.gz", "#{deploy_to}/shared.tar.gz"
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
namespace :symlinks do
|
63
|
+
|
64
|
+
set :app_symlinks, {}
|
65
|
+
|
66
|
+
def new_symlink_style
|
67
|
+
set :app_symlinks, { :public => app_symlinks } if app_symlinks.is_a?(Array)
|
68
|
+
end
|
69
|
+
|
70
|
+
desc "Setup application symlinks in the public"
|
71
|
+
task :setup, :roles => [:app, :web] do
|
72
|
+
new_symlink_style
|
73
|
+
app_symlinks.each do |key, value|
|
74
|
+
dir=(key==:root) ? "" : key+"/"
|
75
|
+
value.each { |link| run "mkdir -p #{shared_path}/#{dir}#{link}" }
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
desc "Link public directories to shared location."
|
80
|
+
task :update, :roles => [:app, :web] do
|
81
|
+
new_symlink_style
|
82
|
+
app_symlinks.each do |key, value|
|
83
|
+
dir=(key==:root) ? "" : key+"/"
|
84
|
+
value.each { |link| run "ln -nfs #{shared_path}/#{dir}#{link} #{current_path}/#{dir}#{link}" }
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Dir.glob("#{File.dirname(__FILE__)}/rails/*").each { |f| require f }
|
@@ -0,0 +1,23 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
namespace :dwell do
|
3
|
+
namespace :ruby_enterprise do
|
4
|
+
|
5
|
+
desc "Install Ruby Enterprise 1.8.6 for Ubuntu 8.04"
|
6
|
+
task :install do
|
7
|
+
run "wget -c http://rubyforge.org/frs/download.php/41041/ruby-enterprise_1.8.6-20080810-i386.deb"
|
8
|
+
sudo "dpkg -i ruby-enterprise_1.8.6-20080810-i386.deb"
|
9
|
+
dwell1.record_install "enterprise_ruby"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
namespace :ruby do
|
14
|
+
|
15
|
+
desc "Install Ruby 1.8.6"
|
16
|
+
task :install do
|
17
|
+
sudo "apt-get install ruby rdoc ri irb libopenssl-ruby1.8 ruby1.8-dev -y"
|
18
|
+
dwell1.record_install "ruby"
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
namespace :dwell do
|
3
|
+
namespace :sqlite do
|
4
|
+
|
5
|
+
desc "Install Sqlite3"
|
6
|
+
task :install do
|
7
|
+
sudo "apt-get install sqlite3 libsqlite3-dev -y"
|
8
|
+
sudo "gem install sqlite3-ruby --no-rdoc --no-ri"
|
9
|
+
dwell1.record_install "sqlite3"
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
namespace :dwell do
|
3
|
+
namespace :ubuntu do
|
4
|
+
|
5
|
+
set :dwell_subversion, nil
|
6
|
+
|
7
|
+
desc "Update apt-get sources"
|
8
|
+
task :update do
|
9
|
+
sudo "apt-get update"
|
10
|
+
end
|
11
|
+
|
12
|
+
desc "Update distribution"
|
13
|
+
task :dist_upgrade do
|
14
|
+
sudo "apt-get dist-upgrade -y"
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Enable build utilities"
|
18
|
+
task :enable_build_tools do
|
19
|
+
sudo "apt-get install build-essential -y"
|
20
|
+
sudo "apt-get install wget -y" # needed later by recipes
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "kill the default message of the day"
|
24
|
+
task :kill_motd do
|
25
|
+
run "test ! -f /etc/motd || #{sudo} mv /etc/motd /etc/motd.silent"
|
26
|
+
end
|
27
|
+
|
28
|
+
task :setup_dwell_storage do
|
29
|
+
dwell1.mkdir "/etc/dwell", :mode => 0755, :owner => "root.admin", :via => :sudo
|
30
|
+
dwell1.append_to_file_if_missing "/etc/dwell/version", "Dwell 0.1 #{dwell_subversion if dwell_subversion}"
|
31
|
+
sudo "touch /etc/dwell/install_log"
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "Prepare ubuntu server"
|
35
|
+
task :prepare do
|
36
|
+
setup_dwell_storage
|
37
|
+
kill_motd
|
38
|
+
update
|
39
|
+
dist_upgrade
|
40
|
+
enable_build_tools
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
Dir.glob("#{File.dirname(__FILE__)}/recipes/*").each { |f| require f if File.file?(f) }
|
2
|
+
Dir.glob("#{File.dirname(__FILE__)}/recipes/bootstrap/*").each { |f| require f }
|
3
|
+
Dir.glob("#{File.dirname(__FILE__)}/recipes/extras/*").each { |f| require f }
|
4
|
+
|
5
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
6
|
+
|
7
|
+
default_run_options[:pty] = true
|
8
|
+
set :keep_releases, 3
|
9
|
+
|
10
|
+
set :which_ruby, :system
|
11
|
+
|
12
|
+
namespace :dwell do
|
13
|
+
|
14
|
+
set :dwell_install, []
|
15
|
+
|
16
|
+
desc "Install Rails Production Environment"
|
17
|
+
task :install do
|
18
|
+
top.dwell.ubuntu.prepare
|
19
|
+
top.dwell.apache.install
|
20
|
+
top.dwell.mysql.install
|
21
|
+
top.dwell.svn.install
|
22
|
+
top.dwell.git.install
|
23
|
+
top.dwell.ruby.install
|
24
|
+
top.dwell.ruby_enterprise.install if which_ruby==:enterprise
|
25
|
+
top.dwell.gems.install
|
26
|
+
top.dwell.passenger.install
|
27
|
+
dwell_install.each do |package_name|
|
28
|
+
top.dwell.send(package_name).install
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'dwell'
|
2
|
+
|
3
|
+
# Application Details
|
4
|
+
set :application, "myapp"
|
5
|
+
set :domain, "myapp.com"
|
6
|
+
set :repository, "svn://myapp.com/trunk"
|
7
|
+
|
8
|
+
# Server-wide Details
|
9
|
+
set :user, "deploy"
|
10
|
+
set :deploy_to, "/var/www/#{application}"
|
11
|
+
server "myserver.com", :app, :web, :db, :primary => true
|
12
|
+
|
13
|
+
## the user to use when creating new databases and such
|
14
|
+
# set :mysql_admin, "root"
|
15
|
+
|
16
|
+
## hosts to automatically add to ssh known_hosts for your deploy user
|
17
|
+
## only github is currently supported
|
18
|
+
# set :known_hosts, [:github]
|
19
|
+
|
20
|
+
## other dwell packages to install on this server
|
21
|
+
# set :dwell_install, ["imagemagick"]
|
22
|
+
|
23
|
+
## a specific rails version your app depends on, will be
|
24
|
+
## gem installed during dwell:install
|
25
|
+
# set :rails_gem_version, "=2.1.2"
|
26
|
+
|
27
|
+
## uncomment this to use enterprise ruby, default is the system ruby
|
28
|
+
# set :which_ruby, :enterprise
|
29
|
+
|
30
|
+
## passenger
|
31
|
+
|
32
|
+
# set :passenger_use_global_queue, "off"
|
33
|
+
# set :passenger_pool_idle_time, 300
|
34
|
+
# set :passenger_rails_spawn_method, "smart"
|
35
|
+
# set :passenger_max_instances_per_app, 0
|
36
|
+
# set :passenger_max_pool_size, 6
|
37
|
+
|
38
|
+
|
39
|
+
## apache
|
40
|
+
|
41
|
+
# set :apache_server_name, nil
|
42
|
+
# set :apache_default_vhost, false
|
43
|
+
# set :apache_ctl, "/etc/init.d/apache2"
|
44
|
+
# set :apache_server_aliases, ["otherhostname.com","alias.net"]
|
45
|
+
# set :apache_ssl_enabled, false
|
46
|
+
# set :apache_ssl_ip, "*"
|
47
|
+
# set :apache_ssl_forward_all, false
|
@@ -0,0 +1,8 @@
|
|
1
|
+
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-<%= passenger_version %>/ext/apache2/mod_passenger.so
|
2
|
+
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-<%= passenger_version %>
|
3
|
+
PassengerRuby <%= passenger_ruby %>
|
4
|
+
|
5
|
+
PassengerPoolIdleTime <%= passenger_pool_idle_time %>
|
6
|
+
PassengerUseGlobalQueue <%= passenger_use_global_queue %>
|
7
|
+
PassengerMaxInstancesPerApp <%= passenger_max_instances_per_app %>
|
8
|
+
PassengerMaxPoolSize <%= passenger_max_pool_size %>
|
@@ -0,0 +1,48 @@
|
|
1
|
+
<VirtualHost <%= apache_ssl_enabled ? apache_ssl_ip : "*" %>:80>
|
2
|
+
ServerName <%= apache_server_name %>
|
3
|
+
<% apache_server_aliases_array.each do |a| %>
|
4
|
+
ServerAlias <%= "#{a}" %>
|
5
|
+
<% end %>
|
6
|
+
DocumentRoot <%= "#{current_path}/public" %>
|
7
|
+
|
8
|
+
<Directory <%= "#{current_path}/public" %>>
|
9
|
+
Options FollowSymLinks
|
10
|
+
AllowOverride None
|
11
|
+
Order allow,deny
|
12
|
+
Allow from all
|
13
|
+
</Directory>
|
14
|
+
|
15
|
+
# passenger
|
16
|
+
RailsEnv <%= rails_env %>
|
17
|
+
RailsSpawnMethod <%= passenger_rails_spawn_method %>
|
18
|
+
|
19
|
+
RewriteEngine On
|
20
|
+
|
21
|
+
<% if apache_ssl_enabled && apache_ssl_forward_all %>
|
22
|
+
RewriteRule ^(.*)$ https://<%= apache_server_name %>$1
|
23
|
+
<% end %>
|
24
|
+
|
25
|
+
<% if scm == :subversion %>
|
26
|
+
# Prevent access to .svn directories
|
27
|
+
RewriteRule ^(.*/)?\.svn/ - [F,L]
|
28
|
+
ErrorDocument 403 "Access Forbidden"
|
29
|
+
<% end %>
|
30
|
+
|
31
|
+
# Check for maintenance file and redirect all requests
|
32
|
+
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
|
33
|
+
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
|
34
|
+
RewriteRule ^.*$ /system/maintenance.html [L]
|
35
|
+
|
36
|
+
# Deflate
|
37
|
+
AddOutputFilterByType DEFLATE text/html text/plain text/xml
|
38
|
+
AddOutputFilterByType DEFLATE application/x-javascript text/css
|
39
|
+
BrowserMatch ^Mozilla/4 gzip-only-text/html
|
40
|
+
BrowserMatch ^Mozilla/4\.0[678] no-gzip
|
41
|
+
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
|
42
|
+
|
43
|
+
# ErrorLog logs/<%= domain %>-error_log
|
44
|
+
# CustomLog logs/<%= domain %>-access_log combined
|
45
|
+
</VirtualHost>
|
46
|
+
|
47
|
+
|
48
|
+
|
@@ -0,0 +1,69 @@
|
|
1
|
+
<VirtualHost <%= apache_ssl_ip %>:443>
|
2
|
+
|
3
|
+
ServerName <%= apache_server_name %>
|
4
|
+
<% apache_server_aliases_array.each do |a| %>
|
5
|
+
ServerAlias <%= "#{a}" %>
|
6
|
+
<% end %>
|
7
|
+
DocumentRoot <%= "#{current_path}/public" %>
|
8
|
+
|
9
|
+
<Directory <%= "#{current_path}/public" %>>
|
10
|
+
Options FollowSymLinks
|
11
|
+
AllowOverride None
|
12
|
+
Order allow,deny
|
13
|
+
Allow from all
|
14
|
+
</Directory>
|
15
|
+
|
16
|
+
# passenger
|
17
|
+
RailsEnv <%= rails_env %>
|
18
|
+
RailsSpawnMethod <%= passenger_rails_spawn_method %>
|
19
|
+
|
20
|
+
RewriteEngine On
|
21
|
+
|
22
|
+
<% if scm == :subversion %>
|
23
|
+
# Prevent access to .svn directories
|
24
|
+
RewriteRule ^(.*/)?\.svn/ - [F,L]
|
25
|
+
ErrorDocument 403 "Access Forbidden"
|
26
|
+
<% end %>
|
27
|
+
|
28
|
+
# Check for maintenance file and redirect all requests
|
29
|
+
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
|
30
|
+
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
|
31
|
+
RewriteRule ^.*$ /system/maintenance.html [L]
|
32
|
+
|
33
|
+
|
34
|
+
# Add header for Mongrel to set HTTPS environment for Rails
|
35
|
+
# RequestHeader set X-Forwarded-Proto "https"
|
36
|
+
|
37
|
+
# Deflate
|
38
|
+
AddOutputFilterByType DEFLATE text/html text/plain text/xml
|
39
|
+
AddOutputFilterByType DEFLATE application/x-javascript text/css
|
40
|
+
BrowserMatch ^Mozilla/4 gzip-only-text/html
|
41
|
+
BrowserMatch ^Mozilla/4\.0[678] no-gzip
|
42
|
+
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
|
43
|
+
|
44
|
+
# SSL Engine Switch
|
45
|
+
SSLEngine on
|
46
|
+
|
47
|
+
# SSL Cipher Suite:
|
48
|
+
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
|
49
|
+
|
50
|
+
# Server Certificate
|
51
|
+
SSLCertificateFile /etc/ssl/certs/<%= domain %>.crt
|
52
|
+
|
53
|
+
# Server Private Key
|
54
|
+
SSLCertificateKeyFile /etc/ssl/private/<%= domain %>.key
|
55
|
+
|
56
|
+
<% Dir.glob("config/dwell/ssl/*").each do |file|
|
57
|
+
next unless file =~ /CA/ %>
|
58
|
+
SSLCACertificateFile /etc/ssl/certs/<%= File.basename(file) %>
|
59
|
+
<% end %>
|
60
|
+
|
61
|
+
BrowserMatch ".*MSIE.*" \
|
62
|
+
nokeepalive ssl-unclean-shutdown \
|
63
|
+
downgrade-1.0 force-response-1.0
|
64
|
+
|
65
|
+
# ErrorLog logs/<%= domain %>-error_log
|
66
|
+
# CustomLog logs/<%= domain %>-access_log combined
|
67
|
+
# CustomLog logs/<%= domain %>-ssl_log \
|
68
|
+
# "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
|
69
|
+
</VirtualHost>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'capistrano'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module Ubuntu1
|
5
|
+
|
6
|
+
def lsb_info
|
7
|
+
get "/etc/lsb-release", "/tmp/lsb-release"
|
8
|
+
all = File.open("/tmp/lsb-release").read
|
9
|
+
all.split("\n").inject({}) do |sum,n|
|
10
|
+
l,v=n.split("=")
|
11
|
+
sum[l.downcase.to_sym]=v.gsub(/^"?(.*)/,"\\1").gsub(/"$/,"")
|
12
|
+
sum
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
Capistrano.plugin :ubuntu1, Ubuntu1
|
data/lib/dwell.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
unless Capistrano::Configuration.respond_to?(:instance)
|
2
|
+
abort "dwell requires Capistrano 2"
|
3
|
+
end
|
4
|
+
|
5
|
+
# abort "Domain variable must be configured:\nset :domain, 'myapp.com'" unless defined?(domain)
|
6
|
+
|
7
|
+
require "#{File.dirname(__FILE__)}/dwell/recipes"
|
8
|
+
require "#{File.dirname(__FILE__)}/dwell/cap_extensions"
|
9
|
+
require "#{File.dirname(__FILE__)}/dwell/ubuntu_extensions"
|