public this repo is viewable by everyone
Clone URL: git://github.com/robbyrussell/rubyurl.git
Changing to capistrano2 for deployments

git-svn-id: https://svn.roundhaus.com/planetargon/rubyurl_2-0/trunk@82 
f0bc2f90-cf15-dc11-b192-0016e6374d05
robbyrussell (author)
5 months ago
commit  a23c6648d28ee631eecde63ac01a571ba1db1255
tree    e68e2d2b7dc35daa7bd39c8fade2ad263bc2f899
parent  47008873ccc7f3e74c34540422dc2d1b44067576
...
 
 
 
...
1
2
3
0
@@ -0,0 +1,3 @@
0
+load 'deploy' if respond_to?(:namespace) # cap2 differentiator
0
+load 'config/deploy'
0
+
...
1
 
 
 
 
2
3
4
...
7
8
9
10
11
12
 
13
14
15
...
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
...
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
 
 
 
...
 
1
2
3
4
5
6
7
...
10
11
12
 
 
 
13
14
15
16
...
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
...
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
141
142
143
144
145
146
 
 
 
 
 
147
148
149
150
151
152
153
 
154
155
156
157
 
158
159
160
161
 
162
163
164
165
 
 
 
 
 
 
 
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
 
 
 
 
 
 
 
 
 
 
 
 
 
192
193
194
195
196
197
198
199
200
201
 
202
203
204
205
206
207
208
209
210
211
 
212
213
214
215
216
217
218
219
 
 
 
220
221
222
223
224
225
226
227
 
 
228
229
230
231
0
@@ -1,4 +1,7 @@
0
-require 'mongrel_cluster/recipes'
0
+# Required for using Mongrel with Capistrano2
0
+# gem install palmtree
0
+require 'palmtree/recipes/mongrel_cluster'
0
+require 'highline/import'
0
 
0
 ########################################################################
0
 # Rails Boxcar - Capistrano Deployment Recipe
0
@@ -7,9 +10,7 @@ require 'mongrel_cluster/recipes'
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
+set :application_name, 'my_cool_app'
0
 
0
 # What is the hostname of your Rails Boxcar server?
0
 # Example:
0
@@ -19,33 +20,36 @@ set :boxcar_server, '198.145.115.75'
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, '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
+set :svn_username, 'rubyurl'
0
+set :svn_repository_url, 'https://svn.roundhaus.com/planetargon/rubyurl_2-0/trunk'
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
+
0
+
0
+
0
+
0
+
0
+
0
+
0
 
0
 ########################################################################
0
 # Advanced Configuration
0
+# Only the courageous of ninjas dare pass this!
0
 ########################################################################
0
 
0
 role :web, boxcar_server
0
@@ -57,83 +61,170 @@ set :user, boxcar_username
0
 set :use_sudo, false
0
 
0
 
0
+set :domain_names, Proc.new { HighLine.ask("What is the primary domain name?") { |q| q.default = "railsboxcar.com" } }
0
+
0
+
0
+# subversion / SCM
0
+# Ask the user for their subversion password
0
+set :svn_password, Proc.new { HighLine.ask("What is your subversion password for #{svn_username}: ") { |q| q.echo = "x" } }
0
+set :repository, Proc.new { "--username #{svn_username} " + "--password #{svn_password} " + "#{svn_repository_url}" }
0
+set :checkout, 'export'
0
+
0
 set :db_development,database_name[:development]
0
 set :db_test, database_name[:test]
0
 set :db_production, database_name[:production]
0
 
0
+# Prompt user to set database user/pass
0
+set :database_username, Proc.new { HighLine.ask("What is your database username? ") { |q| q.default = "dbuser" } }
0
+set :database_host, Proc.new { HighLine.ask("What host is your database running on? ") { |q| q.default = "localhost" } }
0
+set :database_adapter, Proc.new {
0
+ choose do |menu|
0
+ menu.prompt = "What database server will you be using?"
0
+ menu.choices(:postgresql, :mysql)
0
+ end
0
+}
0
+set :database_password, Proc.new { HighLine.ask("What is your database user's password? ") { |q| q.echo = "x" } }
0
+set :database_socket, Proc.new { HighLine.ask("Where is the MySQL socket file? ") { |q| q.default = "/var/run/mysqld/mysqld.sock" } }
0
+set :database_port, Proc.new {
0
+ HighLine.ask("What port does your database run on? ") do |q|
0
+ if database_adapter.to_s == "postgresql"
0
+ q.default = "5432"
0
+ else
0
+ q.default = "3306"
0
+ end
0
+ end
0
+}
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
+set :shared_dir, "#{deploy_to}/shared"
0
+
0
 # mongrel
0
+# What port number should your mongrel cluster start on?
0
+set :mongrel_port, Proc.new { HighLine.ask("What port will your mongrel cluster start with? ") { |q| q.default = "8000" } }
0
+
0
+# How many instances of mongrel should be in your cluster?
0
+set :mongrel_servers, Proc.new {
0
+ choose do |menu|
0
+ menu.prompt = "How many mongrel servers should run?"
0
+ menu.choices(1,2,3)
0
+ end
0
+}
0
+
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
+
0
 # database.yml
0
 desc "Create database.yml in shared/config"
0
 task :after_setup do
0
- database_configuration = render :template => <<-EOF
0
+ puts "###########################################"
0
+ puts " Rails Boxcar - setup process"
0
+ puts "###########################################"
0
+ puts "# STEP 1: Database Configuration"
0
+ puts "###########################################"
0
+
0
+
0
+ today = Time.now.strftime('%b %d, %Y')
0
+
0
+ yml_comment = <<EOF
0
+#
0
+# Generated on #{today} for Rails Boxcar (http://railsboxcar.com)
0
+#
0
+EOF
0
+
0
+ case database_adapter.to_s
0
+ when "postgresql"
0
+ database_configuration = <<EOF
0
+#{yml_comment}
0
 login: &login
0
- adapter: <%= database_adapter %>
0
- host: localhost
0
- port: <%= database_port %>
0
- username: dbuser
0
- password: xy389muw
0
+ adapter: #{database_adapter}
0
+ host: #{database_host}
0
+ port: #{database_port}
0
+ username: #{database_username}
0
+ password: #{database_password}
0
 
0
 development:
0
- database: <%= db_development %>
0
+ database: #{db_development}
0
   <<: *login
0
 
0
 test:
0
- database: <%= db_test %>
0
+ database: #{db_test}
0
   <<: *login
0
 
0
 production:
0
- database: <%= db_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
+ when "mysql"
0
+ database_configuration = <<EOF
0
+#{yml_comment}
0
+login: &login
0
+ adapter: #{database_adapter}
0
+ host: #{database_host}
0
+ port: #{database_port}
0
+ username: #{database_username}
0
+ password: #{database_password}
0
+ socket: #{database_socket}
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
+end
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
+ mongrel_cluster_configuration = <<EOF
0
+#{yml_comment}
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
- run "mkdir -p #{deploy_to}/shared/config"
0
+ puts "###########################################"
0
+ puts "Step 2: Creating necessary directories on\n your Rails Boxcar!"
0
+ puts "###########################################"
0
+ run "mkdir -p #{shared_dir}/config"
0
   
0
+ puts "###########################################"
0
+ puts "Step 3: Uploading database.yml to Boxcar"
0
+ puts "###########################################"
0
+
0
   # Create the database.yml file
0
- put database_configuration, "#{deploy_to}/#{shared_dir}/config/database.yml"
0
+ put database_configuration, "#{shared_dir}/config/database.yml"
0
+
0
+ puts "###########################################"
0
+ puts "Step 4: Uploding mongrel cluster config to\n your Rails Boxcar."
0
+ puts "###########################################"
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
+
0
+ puts "###########################################"
0
+ puts "DONE! Now run cap deploy:cold"
0
+ puts "###########################################"
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
0
+ run "ln -nfs #{shared_dir}/config/database.yml #{release_path}/config/database.yml"
0
+end
0
+
...
5
6
7
8
 
9
10
11
...
5
6
7
 
8
9
10
11
0
@@ -5,7 +5,7 @@
0
 # ENV['RAILS_ENV'] ||= 'production'
0
 
0
 # Specifies gem version of Rails to use when vendor/rails is not present
0
-RAILS_GEM_VERSION = '1.2.3' unless defined? RAILS_GEM_VERSION
0
+RAILS_GEM_VERSION = '1.2.5' unless defined? RAILS_GEM_VERSION
0
 
0
 # Bootstrap the Rails environment, frameworks, and default configuration
0
 require File.join(File.dirname(__FILE__), 'boot')

Comments

    No one has commented yet.