public this repo is viewable by everyone
Clone URL: git://github.com/robbyrussell/rubyurl.git
Adding capistrano recipes so that others can deployz

git-svn-id: https://svn.roundhaus.com/planetargon/rubyurl_2-0/trunk@78 
f0bc2f90-cf15-dc11-b192-0016e6374d05
robbyrussell (author)
8 months ago
commit  be4d41e7e8f5fc4f5b9ea53f2824a9be15152470
tree    406bb51f9396b4e3b4b70d195d266aa13a69575f
parent  187d4b12999ac7085890b70034bc8650b0fae6df
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
0
@@ -0,0 +1,139 @@
0
+require 'mongrel_cluster/recipes'
0
+
0
+########################################################################
0
+# Rails Boxcar - Capistrano Deployment Recipe
0
+# Configuration
0
+########################################################################
0
+# What is the name of your application? (no spaces)
0
+# Example:
0
+# set :application_name, 'my_cool_app'
0
+set :application_name, 'rubyurl'
0
+
0
+set :domain_names, 'rubyurl.com'
0
+
0
+# What is the hostname of your Rails Boxcar server?
0
+# Example:
0
+# set :boxcar_server, 'rc1.railsboxcar.com'
0
+set :boxcar_server, '198.145.115.75'
0
+
0
+# What is the username of your Rails Boxcar user that you want
0
+# to deploy this application with?
0
+# Example:
0
+# set :boxcar_username = 'johnny'
0
+set :boxcar_username, 'rubyurl'
0
+
0
+# Where is your source code repository?
0
+# Example:
0
+# set :repository = 'http://svn.railsboxcar.com/my_cool_app/tags/CURRENT'
0
+set :repository, 'https://svn.roundhaus.com/planetargon/rubyurl_2-0/trunk'
0
+set :checkout, 'export'
0
+
0
+# What database server are you using?
0
+# Example:
0
+set :database_adapter, 'postgresql'
0
+set :database_name, { :development => 'rubyurl_development',
0
+ :test => 'rubyurl_test',
0
+ :production => 'rubyurl_production' }
0
+
0
+# What port number is your database running on?
0
+set :database_port, 5432
0
+
0
+# What port number should your mongrel cluster start on?
0
+set :mongrel_port, 8000
0
+
0
+# How many instances of mongrel should be in your cluster?
0
+set :mongrel_servers, 3
0
+
0
+########################################################################
0
+# Advanced Configuration
0
+########################################################################
0
+
0
+role :web, boxcar_server
0
+role :app, boxcar_server
0
+role :db, boxcar_server, :primary => true
0
+
0
+# user
0
+set :user, boxcar_username
0
+set :use_sudo, false
0
+
0
+
0
+set :db_development,database_name[:development]
0
+set :db_test, database_name[:test]
0
+set :db_production, database_name[:production]
0
+
0
+# directories
0
+set :home, "/home/#{user}"
0
+set :etc, "#{home}/etc"
0
+set :log, "#{home}/log"
0
+set :deploy_to, "#{home}/sites/#{application_name}"
0
+
0
+# mongrel
0
+set :mongrel_conf, "#{etc}/mongrel_cluster.#{application_name}.conf"
0
+set :mongrel_pid, "#{log}/mongrel_cluster.#{application_name}.pid"
0
+set :mongrel_address, '127.0.0.1'
0
+set :mongrel_environment, :production
0
+
0
+# database.yml
0
+desc "Create database.yml in shared/config"
0
+task :after_setup do
0
+ database_configuration = render :template => <<-EOF
0
+login: &login
0
+ adapter: <%= database_adapter %>
0
+ host: localhost
0
+ port: <%= database_port %>
0
+ username: dbuser
0
+ password: xy389muw
0
+
0
+development:
0
+ database: <%= db_development %>
0
+ <<: *login
0
+
0
+test:
0
+ database: <%= db_test %>
0
+ <<: *login
0
+
0
+production:
0
+ database: <%= db_production %>
0
+ <<: *login
0
+EOF
0
+
0
+ mongrel_cluster_configuration = render :template => <<-EOF
0
+---
0
+port: <%= mongrel_port %>
0
+pid_file: <%= mongrel_pid %>
0
+servers: <%= mongrel_servers %>
0
+cwd: <%= deploy_to %>/current
0
+environment: production
0
+EOF
0
+
0
+ nginx_generator_configuration = render :template => <<-EOF
0
+ #######################################################################
0
+ # Add the following to /etc/nginx/nginx.yml
0
+ # Then: cd /etc/nginx; generate_nginx_config nginx.yml nginx.conf
0
+ #######################################################################
0
+ <%= application_name %>:
0
+ # The upstream servers to proxy balance.
0
+ upstream:<% mongrel_servers.to_i.times do |port| %>
0
+ - 127.0.0.1:<%= mongrel_port + port %><% end %>
0
+ # Just a string of server names.
0
+ server_name: <%= domain_names %>
0
+ root: <%= deploy_to %>/current/public
0
+ #######################################################################
0
+EOF
0
+
0
+ run "mkdir -p #{deploy_to}/shared/config"
0
+
0
+ # Create the database.yml file
0
+ put database_configuration, "#{deploy_to}/#{shared_dir}/config/database.yml"
0
+
0
+ # Create mongrel cluster configuration
0
+ put mongrel_cluster_configuration, mongrel_conf
0
+
0
+ # Print the nginx configuration information for the person deploying.
0
+ puts nginx_generator_configuration
0
+end
0
+
0
+desc "Link in the production database.yml"
0
+task :after_update_code do
0
+ run "ln -nfs #{deploy_to}/#{shared_dir}/config/database.yml #{release_path}/config/database.yml"
0
+end
0
\ No newline at end of file
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
0
@@ -0,0 +1,102 @@
0
+# =============================================================================
0
+# A set of rake tasks for invoking the Capistrano automation utility.
0
+# =============================================================================
0
+
0
+# Invoke the given actions via Capistrano
0
+def cap(*parameters)
0
+ begin
0
+ require 'rubygems'
0
+ rescue LoadError
0
+ # no rubygems to load, so we fail silently
0
+ end
0
+
0
+ require 'capistrano/cli'
0
+
0
+ STDERR.puts "Capistrano/Rake integration is deprecated."
0
+ STDERR.puts "Please invoke the 'cap' command directly: `cap #{parameters.join(" ")}'"
0
+
0
+ Capistrano::CLI.new(parameters.map { |param| param.to_s }).execute!
0
+end
0
+
0
+namespace :remote do
0
+ desc "Removes unused releases from the releases directory."
0
+ task(:cleanup) { cap :cleanup }
0
+
0
+ desc "Used only for deploying when the spinner isn't running."
0
+ task(:cold_deploy) { cap :cold_deploy }
0
+
0
+ desc "A macro-task that updates the code, fixes the symlink, and restarts the application servers."
0
+ task(:deploy) { cap :deploy }
0
+
0
+ desc "Similar to deploy, but it runs the migrate task on the new release before updating the symlink."
0
+ task(:deploy_with_migrations) { cap :deploy_with_migrations }
0
+
0
+ desc "Displays the diff between HEAD and what was last deployed."
0
+ task(:diff_from_last_deploy) { cap :diff_from_last_deploy }
0
+
0
+ desc "Disable the web server by writing a \"maintenance.html\" file to the web servers."
0
+ task(:disable_web) { cap :disable_web }
0
+
0
+ desc "Re-enable the web server by deleting any \"maintenance.html\" file."
0
+ task(:enable_web) { cap :enable_web }
0
+
0
+ desc "A simple task for performing one-off commands that may not require a full task to be written for them."
0
+ task(:invoke) { cap :invoke }
0
+
0
+ desc "Run the migrate rake task."
0
+ task(:migrate) { cap :migrate }
0
+
0
+ desc "Restart the FCGI processes on the app server."
0
+ task(:restart) { cap :restart }
0
+
0
+ desc "A macro-task that rolls back the code and restarts the application servers."
0
+ task(:rollback) { cap :rollback }
0
+
0
+ desc "Rollback the latest checked-out version to the previous one by fixing the symlinks and deleting the current release from all servers."
0
+ task(:rollback_code) { cap :rollback_code }
0
+
0
+ desc "Sets group permissions on checkout."
0
+ task(:set_permissions) { cap :set_permissions }
0
+
0
+ desc "Set up the expected application directory structure on all boxes"
0
+ task(:setup) { cap :setup }
0
+
0
+ desc "Begin an interactive Capistrano session."
0
+ task(:shell) { cap :shell }
0
+
0
+ desc "Enumerate and describe every available task."
0
+ task(:show_tasks) { cap :show_tasks, '-q' }
0
+
0
+ desc "Start the spinner daemon for the application (requires script/spin)."
0
+ task(:spinner) { cap :spinner }
0
+
0
+ desc "Update the 'current' symlink to point to the latest version of the application's code."
0
+ task(:symlink) { cap :symlink }
0
+
0
+ desc "Updates the code and fixes the symlink under a transaction"
0
+ task(:update) { cap :update }
0
+
0
+ desc "Update all servers with the latest release of the source code."
0
+ task(:update_code) { cap :update_code }
0
+
0
+ desc "Update the currently released version of the software directly via an SCM update operation"
0
+ task(:update_current) { cap :update_current }
0
+
0
+ desc "Execute a specific action using capistrano"
0
+ task :exec do
0
+ unless ENV['ACTION']
0
+ raise "Please specify an action (or comma separated list of actions) via the ACTION environment variable"
0
+ end
0
+
0
+ actions = ENV['ACTION'].split(",")
0
+ actions.concat(ENV['PARAMS'].split(" ")) if ENV['PARAMS']
0
+
0
+ cap(*actions)
0
+ end
0
+end
0
+
0
+desc "Push the latest revision into production (delegates to remote:deploy)"
0
+task :deploy => "remote:deploy"
0
+
0
+desc "Rollback to the release before the current release in production (delegates to remote:rollback)"
0
+task :rollback => "remote:rollback"

Comments

    No one has commented yet.