brightbox 2.1.2 → 2.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.
data/bin/brightbox CHANGED
@@ -55,6 +55,10 @@ opts = OptionParser.new do |opts|
55
55
  "Brightbox virtual server",
56
56
  "(e.g: example-001.vm.brightbox.net)\n"
57
57
  ) { |value| @server = value }
58
+
59
+ opts.on("-a TYPE", "--app TYPE", [:mongrel, :passenger],
60
+ "App server type, mongrel or passenger"
61
+ ) { |value| @app_server = value }
58
62
 
59
63
  begin
60
64
  opts.parse!(ARGV)
@@ -78,6 +82,17 @@ def unindent(string)
78
82
  string.strip.gsub(/^#{indentation}/, "")
79
83
  end
80
84
 
85
+ def deploy_requires(app_server)
86
+ header = %Q{gem 'brightbox', '>=#{Brightbox::VERSION}'
87
+ require 'brightbox/recipes'
88
+ }
89
+ case app_server
90
+ when :passenger
91
+ header << %Q{require 'brightbox/passenger'}
92
+ end
93
+ return header
94
+ end
95
+
81
96
  @domain ||= @server
82
97
  @application ||= @server.gsub(/(-\d{3})?\..*\Z/,'')
83
98
 
@@ -149,36 +164,46 @@ unless Rake::Task.task_defined?("db:check:config")
149
164
  pe "database name should start with '\#{config['username']}' if using cluster"
150
165
  end
151
166
  end
167
+
168
+ require 'yaml'
169
+
170
+ def read_database_yml
171
+ db_yml = File.join(File.dirname(__FILE__), "..", "..", "config", "database.yml")
172
+ if File.exist?(db_yml)
173
+ return YAML.load(File.open(db_yml))
174
+ else
175
+ return {}
176
+ end
177
+ end
152
178
 
153
- namespace(:db) do
154
- namespace(:check) do
155
- desc "Check database.yml config"
156
- task :config => :environment do
157
- p "Checking database mysql configuration..."
158
- if config=ActiveRecord::Base.configurations[RAILS_ENV]
159
- case config['adapter']
160
- when nil
161
- pe "adapter entry missing."
162
- when 'mysql'
163
- brightbox_sanity_checks(config)
164
- else
165
- pe "using \#{config['adapter']} - halting checks"
166
- end
179
+ namespace(:db) do
180
+ namespace(:check) do
181
+ desc "Check database.yml config"
182
+ task :config do
183
+ p "Checking database mysql configuration..."
184
+ if config=read_database_yml[RAILS_ENV]
185
+ case config['adapter']
186
+ when nil
187
+ pe "adapter entry missing."
188
+ when 'mysql'
189
+ brightbox_sanity_checks(config)
167
190
  else
168
- pe "section missing."
191
+ pe "using \#{config['adapter']} - halting checks"
169
192
  end
193
+ else
194
+ pe "section missing."
170
195
  end
171
196
  end
172
197
  end
173
- end
198
+ end
199
+ end
174
200
 
175
201
 
176
202
  FILE
177
203
 
178
204
  "config/deploy.rb" => unindent(<<-FILE),
179
205
  ## Generated with '#{opts.program_name}' on #{Time.now}
180
- gem 'brightbox', '>=#{Brightbox::VERSION}'
181
- require 'brightbox/recipes'
206
+ #{deploy_requires(@app_server)}
182
207
 
183
208
  # The name of your application. Used for deployment directory and filenames
184
209
  # and Apache configs. Should be unique on the Brightbox
@@ -286,6 +311,30 @@ end
286
311
  # or be explicit
287
312
  # set :scm, :subversion
288
313
 
314
+ ## Deployment settings
315
+ # The brightbox gem deploys as the user 'rails' by default and
316
+ # into the 'production' environment. You can change these as required.
317
+ # set :user, "rails"
318
+ # set :rails_env, :production
319
+
320
+ ## Command running settings
321
+ # use_sudo is switched off by default so that commands are run
322
+ # directly as 'user' by the run command. If you switch on sudo
323
+ # make sure you set the :runner variable - which is the user the
324
+ # capistrano default tasks use to execute commands.
325
+ # NB. This just affects the default recipes unless you use the
326
+ # 'try_sudo' command to run your commands.
327
+ # set :use_sudo, false
328
+ # set :runner, user
329
+
330
+ ## Dependencies
331
+ # Set the commands and gems that your application requires. e.g.
332
+ # depend :remote, :gem, "will_paginate", ">=2.2.2"
333
+ # depend :remote, :command, "brightbox"\n\n
334
+ FILE
335
+ }
336
+
337
+ mongrel_deploy = unindent(<<-FILE
289
338
  ## Mongrel settings
290
339
  # Addresses that Mongrel listens on. Defaults to :local
291
340
  # Use :remote if your mongrels are on a different host to the web
@@ -307,29 +356,31 @@ end
307
356
  # set :mongrel_max_memory, 110
308
357
  # Maximum cpu allowable per mongrel. Defaults to 80%
309
358
  # set :mongrel_max_cpu, 80
310
-
311
- ## Deployment settings
312
- # The brightbox gem deploys as the user 'rails' by default and
313
- # into the 'production' environment. You can change these as required.
314
- # set :user, "rails"
315
- # set :rails_env, :production
316
-
317
- ## Command running settings
318
- # use_sudo is switched off by default so that commands are run
319
- # directly as 'user' by the run command. If you switch on sudo
320
- # make sure you set the :runner variable - which is the user the
321
- # capistrano default tasks use to execute commands.
322
- # NB. This just affects the default recipes unless you use the
323
- # 'try_sudo' command to run your commands.
324
- # set :use_sudo, false
325
- # set :runner, user
326
-
327
- ## Dependencies
328
- # Set the commands and gems that your application requires. e.g.
329
- # depend :remote, :gem, "will_paginate", ">=2.2.2"
330
- # depend :remote, :command, "brightbox"
331
359
  FILE
332
- }
360
+ )
361
+
362
+ passenger_deploy = unindent(<<-FILE
363
+ ## Ruby Enterprise
364
+ # Use the experimental Brightbox Ruby Enterprise Package for Ubuntu
365
+ # Don't enable this option unless you're testing this out as it is
366
+ # currently not recommended for production use
367
+ # set :use_ree, true
368
+
369
+ ## Passenger Configuration
370
+ # Set the method of restarting passenger
371
+ # Defaults to :hard which is used to instantly free up database connections
372
+ # :soft uses the standard touch tmp/restart.txt which leaves database connections
373
+ # lingering until the workers time out
374
+ # set :passenger_restart_strategy, :hard
375
+ FILE
376
+ )
377
+
378
+ case @app_server
379
+ when :passenger
380
+ files["config/deploy.rb"] << passenger_deploy
381
+ when :mongrel
382
+ files["config/deploy.rb"] << mongrel_deploy
383
+ end
333
384
 
334
385
  base = ARGV.shift
335
386
  files.each do |file, content|
data/brightbox-gemspec.rb CHANGED
@@ -20,7 +20,7 @@
20
20
  require File.join(File.dirname(__FILE__),"lib/brightbox/version")
21
21
  def add_common(spec)
22
22
  spec.version = Brightbox::VERSION
23
- spec.authors = ["John Leach","Neil Wilson"]
23
+ spec.authors = ["John Leach","Neil Wilson","David Smalley"]
24
24
  spec.email = "support@brightbox.co.uk"
25
25
  spec.homepage = "http://wiki.brightbox.co.uk/docs:thebrightboxgem"
26
26
  spec.rubyforge_project = 'brightbox'
@@ -0,0 +1,21 @@
1
+ # Brightbox - Easy Ruby Web Application Deployment
2
+ # Copyright (C) 2008, David Smalley, Brightbox Systems
3
+ #
4
+ # This file is part of the Brightbox deployment system
5
+ #
6
+ # Brightbox gem is free software: you can redistribute it and/or modify it
7
+ # under the terms of the GNU Affero General Public License as published
8
+ # by the Free Software Foundation, either version 3 of the License,
9
+ # or (at your option) any later version.
10
+ #
11
+ # This program is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ # Affero General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Affero General
17
+ # Public License along with this program. If not, see
18
+ # <http://www.gnu.org/licenses/>.
19
+ #
20
+ Capistrano::Configuration.instance(true).load File.join(File.dirname(__FILE__), "recipes", "deploy", "passenger.rb")
21
+ Capistrano::Configuration.instance(true).load File.join(File.dirname(__FILE__), "recipes", "configure", "passenger.rb")
@@ -17,6 +17,7 @@
17
17
  # Public License along with this program. If not, see
18
18
  # <http://www.gnu.org/licenses/>.
19
19
  #
20
+ require File.dirname(__FILE__) + '/version'
20
21
  Dir[File.join(File.dirname(__FILE__), 'recipes', '*.rb')].each do |recipe|
21
22
  Capistrano::Configuration.instance(true).load recipe
22
23
  end
@@ -19,19 +19,16 @@
19
19
  #
20
20
  # Hook tasks into the standard deployment system
21
21
 
22
+ # Some mongrel specific callbacks have been moved to configure/mongrel.rb
23
+
22
24
  after "deploy:setup",
23
25
  "deploy:shared:global:setup",
24
26
  "deploy:shared:local:setup",
25
27
  "configure:maintenance",
26
28
  "configure:logrotation",
27
- "configure:monit",
28
- "configure:mongrel",
29
29
  "configure:apache",
30
30
  "configure:nginx"
31
31
 
32
- after "deploy:cold",
33
- "deploy:monit:reload"
34
-
35
32
  after "deploy:finalize_update",
36
33
  "deploy:shared:global:symlink",
37
34
  "deploy:shared:local:symlink",
@@ -40,7 +37,6 @@ after "deploy:finalize_update",
40
37
  after "deploy:update",
41
38
  "deploy:cleanup"
42
39
 
43
-
44
40
  after "deploy:start",
45
41
  "deploy:web:reload_if_new"
46
42
 
@@ -19,145 +19,38 @@
19
19
  #
20
20
 
21
21
  def monit_setup
22
- "railsapp-monit"
22
+ "railsapp-monit _#{::Version}_"
23
23
  end
24
24
  depend :remote, :command, monit_setup
25
25
 
26
26
  def apache_setup
27
- "railsapp-apache"
27
+ "railsapp-apache _#{::Version}_"
28
28
  end
29
29
  depend :remote, :command, apache_setup
30
30
 
31
31
  def nginx_setup
32
- "railsapp-nginx"
32
+ "railsapp-nginx _#{::Version}_"
33
33
  end
34
34
  depend :remote, :command, nginx_setup
35
35
 
36
36
  def mongrel_setup
37
- "railsapp-mongrel"
37
+ "railsapp-mongrel _#{::Version}_"
38
38
  end
39
39
  depend :remote, :command, mongrel_setup
40
40
 
41
41
  def logrotate_setup
42
- "railsapp-logrotate"
42
+ "railsapp-logrotate _#{::Version}_"
43
43
  end
44
44
  depend :remote, :command, logrotate_setup
45
45
 
46
46
  def maintenance_setup
47
- "railsapp-maintenance"
47
+ "railsapp-maintenance _#{::Version}_"
48
48
  end
49
49
  depend :remote, :command, maintenance_setup
50
50
 
51
- namespace :configure do
52
-
53
- [:nginx, :apache].each do |webserver|
54
- desc %Q{
55
- [internal]Create #{webserver.to_s} config. Creates a load balancing virtual host \
56
- configuration based upon your specified settings
57
-
58
- :application Name of the application
59
- :domain Domain name which will point to the application
60
- :domain_aliases Comma separated list of aliased for the main domain
61
- :mongrel_host Name of application layer host (default localhost)
62
- :mongrel_port Start port of the mongrel cluster (default 8000)
63
- :mongrel_servers Number of servers on app host (default 2)
64
- :ssl_certificate Create SSL configuration with certificate
65
- :ssl_key Name of private key to use with certificate
66
-
67
- }
68
- task webserver, :roles => :web, :except => {:no_release => true} do
69
- app_hosts = case mongrel_host
70
- when :local
71
- "localhost"
72
- when :remote
73
- roles[:app].servers.join(",")
74
- else
75
- mongrel_host
76
- end
77
- sudo on_one_line( <<-END
78
- #{send(webserver.to_s + "_setup")}
79
- -n #{application}
80
- -d #{domain}
81
- #{'-a '+domain_aliases if domain_aliases}
82
- -w #{File.join(current_path, 'public')}
83
- -h #{app_hosts}
84
- -p #{mongrel_port}
85
- -s #{mongrel_servers}
86
- #{'-m '+max_age if max_age}
87
- #{'-c '+ssl_certificate if ssl_certificate}
88
- #{'-k '+ssl_key if ssl_key}
89
- END
90
- )
91
- end
92
- end
51
+ Capistrano::Configuration.instance(true).load File.join(File.dirname(__FILE__), 'configure', 'mongrel.rb')
93
52
 
94
- desc %Q{
95
- [internal]Create Mongrel config. Creates a set of mongrels running \
96
- on the specified ports of the application server(s).
97
-
98
- :application Name of the application
99
- :mongrel_host Address for mongrels to listen to (default localhost)
100
- :mongrel_port Start port of the mongrel cluster (default 8000)
101
- :mongrel_servers Number of servers on app host (default 2)
102
- :mongrel_pid_file The name of the file containing the mongrel PID
103
-
104
- }
105
- task :mongrel, :roles => :app, :except => {:no_release => true} do
106
- listen_address = case mongrel_host
107
- when :local
108
- "localhost"
109
- when :remote
110
- "0.0.0.0"
111
- else
112
- mongrel_host
113
- end
114
- sudo on_one_line( <<-END
115
- #{mongrel_setup}
116
- -n #{application}
117
- -r #{current_path}
118
- -p #{mongrel_port}
119
- -s #{mongrel_servers}
120
- -h #{listen_address}
121
- -C #{mongrel_config_file}
122
- -P #{mongrel_pid_file}
123
- -e #{rails_env}
124
- END
125
- )
126
- end
127
-
128
- desc %Q{
129
- [internal]Create Monit config. Build a monit configuraton file \
130
- to look after this application
131
-
132
- :application Name of the application
133
- :mongrel_host Name of application layer host (default localhost)
134
- :mongrel_port Start port of the mongrel cluster (default 8000)
135
- :mongrel_servers Number of servers on app host (default 2)
136
-
137
- }
138
- task :monit, :roles => :app, :except => {:no_release => true} do
139
- listen_address = case mongrel_host
140
- when :local, :remote
141
- "localhost"
142
- else
143
- mongrel_host
144
- end
145
- sudo on_one_line( <<-END
146
- #{monit_setup}
147
- -n #{application}
148
- -u #{user}
149
- -r #{current_path}
150
- -h #{listen_address}
151
- -p #{mongrel_port}
152
- -s #{mongrel_servers}
153
- -C #{mongrel_config_file}
154
- -P #{mongrel_pid_file}
155
- -U #{mongrel_check_url}
156
- -m #{mongrel_max_memory}
157
- -c #{mongrel_max_cpu}
158
- END
159
- )
160
- end
53
+ namespace :configure do
161
54
 
162
55
  desc %Q{
163
56
  [internal]Create logrotation config. Build a logrotate configuraton file \
@@ -0,0 +1,139 @@
1
+ # Brightbox - Easy Ruby Web Application Deployment
2
+ # Copyright (C) 2008, David Smalley, Brightbox Systems
3
+ #
4
+ # This file is part of the Brightbox deployment system
5
+ #
6
+ # Brightbox gem is free software: you can redistribute it and/or modify it
7
+ # under the terms of the GNU Affero General Public License as published
8
+ # by the Free Software Foundation, either version 3 of the License,
9
+ # or (at your option) any later version.
10
+ #
11
+ # This program is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ # Affero General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Affero General
17
+ # Public License along with this program. If not, see
18
+ # <http://www.gnu.org/licenses/>.
19
+ #
20
+
21
+ after "deploy:setup",
22
+ "configure:monit",
23
+ "configure:mongrel"
24
+
25
+ after "deploy:cold",
26
+ "deploy:monit:reload"
27
+
28
+ namespace :configure do
29
+
30
+ [:nginx, :apache].each do |webserver|
31
+ desc %Q{
32
+ [internal]Create #{webserver.to_s} config. Creates a load balancing virtual host \
33
+ configuration based upon your specified settings
34
+
35
+ :application Name of the application
36
+ :domain Domain name which will point to the application
37
+ :domain_aliases Comma separated list of aliased for the main domain
38
+ :mongrel_host Name of application layer host (default localhost)
39
+ :mongrel_port Start port of the mongrel cluster (default 8000)
40
+ :mongrel_servers Number of servers on app host (default 2)
41
+ :ssl_certificate Create SSL configuration with certificate
42
+ :ssl_key Name of private key to use with certificate
43
+
44
+ }
45
+ task webserver, :roles => :web, :except => {:no_release => true} do
46
+ app_hosts = case mongrel_host
47
+ when :local
48
+ "localhost"
49
+ when :remote
50
+ roles[:app].servers.join(",")
51
+ else
52
+ mongrel_host
53
+ end
54
+ sudo on_one_line( <<-END
55
+ #{send(webserver.to_s + "_setup")}
56
+ -n #{application}
57
+ -d #{domain}
58
+ #{'-a '+domain_aliases if domain_aliases}
59
+ -w #{File.join(current_path, 'public')}
60
+ -h #{app_hosts}
61
+ -p #{mongrel_port}
62
+ -s #{mongrel_servers}
63
+ #{'-m '+max_age if max_age}
64
+ #{'-c '+ssl_certificate if ssl_certificate}
65
+ #{'-k '+ssl_key if ssl_key}
66
+ END
67
+ )
68
+ end
69
+ end
70
+
71
+ desc %Q{
72
+ [internal]Create Mongrel config. Creates a set of mongrels running \
73
+ on the specified ports of the application server(s).
74
+
75
+ :application Name of the application
76
+ :mongrel_host Address for mongrels to listen to (default localhost)
77
+ :mongrel_port Start port of the mongrel cluster (default 8000)
78
+ :mongrel_servers Number of servers on app host (default 2)
79
+ :mongrel_pid_file The name of the file containing the mongrel PID
80
+
81
+ }
82
+ task :mongrel, :roles => :app, :except => {:no_release => true} do
83
+ listen_address = case mongrel_host
84
+ when :local
85
+ "localhost"
86
+ when :remote
87
+ "0.0.0.0"
88
+ else
89
+ mongrel_host
90
+ end
91
+ sudo on_one_line( <<-END
92
+ #{mongrel_setup}
93
+ -n #{application}
94
+ -r #{current_path}
95
+ -p #{mongrel_port}
96
+ -s #{mongrel_servers}
97
+ -h #{listen_address}
98
+ -C #{mongrel_config_file}
99
+ -P #{mongrel_pid_file}
100
+ -e #{rails_env}
101
+ END
102
+ )
103
+ end
104
+
105
+ desc %Q{
106
+ [internal]Create Monit config. Build a monit configuraton file \
107
+ to look after this application
108
+
109
+ :application Name of the application
110
+ :mongrel_host Name of application layer host (default localhost)
111
+ :mongrel_port Start port of the mongrel cluster (default 8000)
112
+ :mongrel_servers Number of servers on app host (default 2)
113
+
114
+ }
115
+ task :monit, :roles => :app, :except => {:no_release => true} do
116
+ listen_address = case mongrel_host
117
+ when :local, :remote
118
+ "localhost"
119
+ else
120
+ mongrel_host
121
+ end
122
+ sudo on_one_line( <<-END
123
+ #{monit_setup}
124
+ -n #{application}
125
+ -u #{user}
126
+ -r #{current_path}
127
+ -h #{listen_address}
128
+ -p #{mongrel_port}
129
+ -s #{mongrel_servers}
130
+ -C #{mongrel_config_file}
131
+ -P #{mongrel_pid_file}
132
+ -U #{mongrel_check_url}
133
+ -m #{mongrel_max_memory}
134
+ -c #{mongrel_max_cpu}
135
+ END
136
+ )
137
+ end
138
+
139
+ end
@@ -0,0 +1,57 @@
1
+ # Brightbox - Easy Ruby Web Application Deployment
2
+ # Copyright (C) 2008, David Smalley, Brightbox Systems
3
+ #
4
+ # This file is part of the Brightbox deployment system
5
+ #
6
+ # Brightbox gem is free software: you can redistribute it and/or modify it
7
+ # under the terms of the GNU Affero General Public License as published
8
+ # by the Free Software Foundation, either version 3 of the License,
9
+ # or (at your option) any later version.
10
+ #
11
+ # This program is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ # Affero General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Affero General
17
+ # Public License along with this program. If not, see
18
+ # <http://www.gnu.org/licenses/>.
19
+ #
20
+ depend :remote, :gem, "rack", ">=0.9.0"
21
+
22
+ namespace :configure do
23
+
24
+ desc %Q{
25
+ [internal]Create Apache config. Creates a load balancing virtual host \
26
+ configuration based upon your specified settings
27
+
28
+ :application Name of the application
29
+ :domain Domain name which will point to the application
30
+ :domain_aliases Comma separated list of aliased for the main domain
31
+ :ssl_certificate Create SSL configuration with certificate
32
+ :ssl_key Name of private key to use with certificate
33
+
34
+ }
35
+ task :apache, :roles => :web, :except => {:no_release => true} do
36
+ sudo on_one_line( <<-END
37
+ #{send("apache_setup")}
38
+ -n #{application}
39
+ -d #{domain}
40
+ #{'-a '+domain_aliases if domain_aliases}
41
+ -w #{File.join(current_path, 'public')}
42
+ --passenger
43
+ --railsenv #{rails_env}
44
+ #{'-m '+max_age if max_age}
45
+ #{'-c '+ssl_certificate if ssl_certificate}
46
+ #{'-k '+ssl_key if ssl_key}
47
+ END
48
+ )
49
+ end
50
+
51
+ task :mongrel, :roles => :app, :except => {:no_release => true} do
52
+ end
53
+
54
+ task :monit, :roles => :app, :except => {:no_release => true} do
55
+ end
56
+
57
+ end
@@ -19,49 +19,10 @@
19
19
  #
20
20
  # Override standard tasks that don't do what we want
21
21
 
22
- namespace :deploy do
23
-
24
- def mongrel_command
25
- "/usr/bin/mongrel_rails"
26
- end
27
- depend :remote, :command, mongrel_command
28
-
29
- def monit_command
30
- "/usr/sbin/monit"
31
- end
32
- depend :remote, :command, monit_command
33
-
34
- def mongrel_cluster_command(event)
35
- "#{mongrel_command} cluster::#{event} -C #{mongrel_config_file}" <<
36
- if event == "status"
37
- ""
38
- else
39
- " --clean"
40
- end
41
- end
42
-
43
- def monitor_cluster_command(event)
44
- case event
45
- when "start","restart"
46
- "#{monit_command} -g #{application} monitor all"
47
- when "stop"
48
- "#{monit_command} -g #{application} unmonitor all"
49
- else
50
- nil
51
- end
52
- end
22
+ # By default we require mongrel. In future we can just switch the default to passenger
23
+ Capistrano::Configuration.instance(true).load File.join(File.dirname(__FILE__), 'deploy', 'mongrel.rb')
53
24
 
54
- #Override start, stop and restart so that they use mongrel to restart the
55
- #application servers
56
- %w(start stop restart status).each do |event|
57
- desc "Ask mongrel to #{event} your application."
58
- task event, :roles => :app, :except => {:no_release => true } do
59
- try_sudo mongrel_cluster_command(event)
60
- if cmd = monitor_cluster_command(event)
61
- sudo cmd
62
- end
63
- end
64
- end
25
+ namespace :deploy do
65
26
 
66
27
  namespace :web do
67
28
 
@@ -111,21 +72,11 @@ namespace :deploy do
111
72
 
112
73
  end
113
74
 
114
- namespace :monit do
115
-
116
- desc %Q{
117
- Reload monit
118
- }
119
- task :reload do
120
- sudo "#{monit_command} reload"
121
- end
122
-
123
- end
124
-
125
75
  desc %Q{Setup the directories and deploy the initial version of the
126
76
  application
127
77
  }
128
78
  task :initial do
79
+ gems.check_server_tools
129
80
  setup
130
81
  cold
131
82
  end
@@ -136,7 +87,9 @@ namespace :deploy do
136
87
  Execute Rake tasks that need to be run once per system
137
88
  }
138
89
  task :singleton, :roles => :db, :only => {:primary => true} do
139
- run rake_task("db:check:config")
90
+ unless disable_db_check
91
+ run rake_task("db:check:config")
92
+ end
140
93
  run rake_task("db:create")
141
94
  end
142
95
 
@@ -151,8 +104,8 @@ namespace :deploy do
151
104
  Execute Rake tasks
152
105
  }
153
106
  task :default do
154
- singleton
155
107
  global
108
+ singleton
156
109
  end
157
110
  end
158
111
 
@@ -0,0 +1,76 @@
1
+ # Brightbox - Easy Ruby Web Application Deployment
2
+ # Copyright (C) 2008, David Smalley, Brightbox Systems
3
+ #
4
+ # This file is part of the Brightbox deployment system
5
+ #
6
+ # Brightbox gem is free software: you can redistribute it and/or modify it
7
+ # under the terms of the GNU Affero General Public License as published
8
+ # by the Free Software Foundation, either version 3 of the License,
9
+ # or (at your option) any later version.
10
+ #
11
+ # This program is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ # Affero General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Affero General
17
+ # Public License along with this program. If not, see
18
+ # <http://www.gnu.org/licenses/>.
19
+ #
20
+
21
+ namespace :deploy do
22
+
23
+ def mongrel_command
24
+ "/usr/bin/mongrel_rails"
25
+ end
26
+ depend :remote, :command, mongrel_command
27
+
28
+ def monit_command
29
+ "/usr/sbin/monit"
30
+ end
31
+ depend :remote, :command, monit_command
32
+
33
+ def mongrel_cluster_command(event)
34
+ "#{mongrel_command} cluster::#{event} -C #{mongrel_config_file}" <<
35
+ if event == "status"
36
+ ""
37
+ else
38
+ " --clean"
39
+ end
40
+ end
41
+
42
+ def monitor_cluster_command(event)
43
+ case event
44
+ when "start","restart"
45
+ "#{monit_command} -g #{application} monitor all"
46
+ when "stop"
47
+ "#{monit_command} -g #{application} unmonitor all"
48
+ else
49
+ nil
50
+ end
51
+ end
52
+
53
+ #Override start, stop and restart so that they use mongrel to restart the
54
+ #application servers
55
+ %w(start stop restart status).each do |event|
56
+ desc "Ask mongrel to #{event} your application."
57
+ task event, :roles => :app, :except => {:no_release => true } do
58
+ try_sudo mongrel_cluster_command(event)
59
+ if cmd = monitor_cluster_command(event)
60
+ sudo cmd
61
+ end
62
+ end
63
+ end
64
+
65
+ namespace :monit do
66
+
67
+ desc %Q{
68
+ Reload monit
69
+ }
70
+ task :reload do
71
+ sudo "#{monit_command} reload"
72
+ end
73
+
74
+ end
75
+
76
+ end
@@ -0,0 +1,55 @@
1
+ # Brightbox - Easy Ruby Web Application Deployment
2
+ # Copyright (C) 2008, David Smalley, Brightbox Systems
3
+ #
4
+ # This file is part of the Brightbox deployment system
5
+ #
6
+ # Brightbox gem is free software: you can redistribute it and/or modify it
7
+ # under the terms of the GNU Affero General Public License as published
8
+ # by the Free Software Foundation, either version 3 of the License,
9
+ # or (at your option) any later version.
10
+ #
11
+ # This program is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ # Affero General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU Affero General
17
+ # Public License along with this program. If not, see
18
+ # <http://www.gnu.org/licenses/>.
19
+ #
20
+
21
+ namespace :deploy do
22
+
23
+ #Override start and stop, they are useless for passenger
24
+ %w(start stop status).each do |event|
25
+ desc "Dummy command to #{event} your application, not used by Passenger."
26
+ task event, :roles => :app, :except => {:no_release => true } do
27
+ end
28
+ end
29
+
30
+ desc "Restart your application using passenger."
31
+ task :restart, :roles => :app, :except => {:no_release => true} do
32
+ case passenger_restart_strategy
33
+ when :hard
34
+ deploy.passenger.hard_restart
35
+ when :soft
36
+ deploy.passenger.soft_restart
37
+ end
38
+ end
39
+
40
+ namespace :passenger do
41
+
42
+ desc "Hard restart your passenger instances by killing the dispatcher"
43
+ task :hard_restart, :roles => :app, :except => {:no_release => true} do
44
+ soft_restart
45
+ sudo "kill \$( passenger-memory-stats | grep 'Passenger spawn server' | awk '{ print \$1 }' )"
46
+ end
47
+
48
+ desc "Soft restart you passenger instances by issuing touch tmp/restart.txt"
49
+ task :soft_restart, :roles => :app, :except => {:no_release => true} do
50
+ run "touch #{current_path}/tmp/restart.txt"
51
+ end
52
+
53
+ end
54
+
55
+ end
@@ -19,6 +19,20 @@
19
19
  #
20
20
 
21
21
  namespace :gems do
22
+
23
+ desc "[internal]Install the matching brightbox-server-tools gem for this client gem version"
24
+ task :check_server_tools, :except => {:no_release => true} do
25
+ puts "Checking for brightbox-server-tools at #{::Version}"
26
+ install_gem("brightbox-server-tools", ::Version)
27
+ end
28
+
29
+ def install_gem(gem, version)
30
+ sudo %Q{sh -c "
31
+ gem spec #{gem} --version '#{version}' 2>/dev/null|egrep -q '^name:' ||
32
+ sudo gem install --no-ri --no-rdoc --version '#{version}' #{gem}"
33
+ }
34
+ end
35
+
22
36
 
23
37
  def gem_dependencies?
24
38
  (fetch(:dependencies,{})[:remote]||{})[:gem]
@@ -30,10 +44,7 @@ namespace :gems do
30
44
  gem = gemspec[0]
31
45
  version = gemspec[1]
32
46
  puts "Checking for #{gem} at #{version}"
33
- sudo %Q{sh -c "
34
- gem spec #{gem} --version '#{version}' 2>/dev/null|egrep -q '^name:' ||
35
- sudo gem install -y --no-ri --no-rdoc --version '#{version}' #{gem}"
36
- }
47
+ install_gem(gem, version)
37
48
  end
38
49
  end
39
50
 
@@ -43,6 +54,7 @@ namespace :gems do
43
54
  task :install, :except => {:no_release => true} do
44
55
  if gem_dependencies?
45
56
  install_gems
57
+ sudo rake_task("gems:install")
46
58
  else
47
59
  sudo rake_task("gems:install")
48
60
  end
@@ -39,6 +39,9 @@ _cset :domain_aliases, nil
39
39
  _cset :max_age, nil
40
40
  _cset :user, "rails"
41
41
  _cset :runner, user
42
+ _cset :disable_db_check, false
43
+ _cset :use_ree, false
44
+ _cset :passenger_restart_strategy, :hard
42
45
  _cset :use_sudo, false
43
46
  _cset :ssl_certificate, nil
44
47
  _cset :ssl_key, nil
@@ -1,5 +1,5 @@
1
1
  module Brightbox
2
- VERSION = "2.1.2"
2
+ VERSION = "2.2"
3
3
  end
4
4
  # Set global scope version so that OptionParser picks it up.
5
5
  ::Version = Brightbox::VERSION
metadata CHANGED
@@ -1,16 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brightbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: "2.2"
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Leach
8
8
  - Neil Wilson
9
+ - David Smalley
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
13
 
13
- date: 2008-10-08 00:00:00 +01:00
14
+ date: 2009-01-09 00:00:00 +00:00
14
15
  default_executable:
15
16
  dependencies:
16
17
  - !ruby/object:Gem::Dependency
@@ -35,17 +36,22 @@ files:
35
36
  - LICENSE
36
37
  - Rakefile
37
38
  - brightbox-gemspec.rb
39
+ - lib/brightbox/maintenance.rb
40
+ - lib/brightbox/passenger.rb
41
+ - lib/brightbox/recipes/callbacks.rb
42
+ - lib/brightbox/recipes/configure/mongrel.rb
43
+ - lib/brightbox/recipes/configure/passenger.rb
38
44
  - lib/brightbox/recipes/configure.rb
39
- - lib/brightbox/recipes/variables.rb
45
+ - lib/brightbox/recipes/database.rb
46
+ - lib/brightbox/recipes/deploy/mongrel.rb
47
+ - lib/brightbox/recipes/deploy/passenger.rb
48
+ - lib/brightbox/recipes/deploy.rb
40
49
  - lib/brightbox/recipes/gems.rb
41
50
  - lib/brightbox/recipes/helpers.rb
42
51
  - lib/brightbox/recipes/shared_assets.rb
43
- - lib/brightbox/recipes/callbacks.rb
44
- - lib/brightbox/recipes/database.rb
45
- - lib/brightbox/recipes/deploy.rb
46
- - lib/brightbox/version.rb
52
+ - lib/brightbox/recipes/variables.rb
47
53
  - lib/brightbox/recipes.rb
48
- - lib/brightbox/maintenance.rb
54
+ - lib/brightbox/version.rb
49
55
  - bin/brightbox
50
56
  has_rdoc: false
51
57
  homepage: http://wiki.brightbox.co.uk/docs:thebrightboxgem
@@ -69,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
75
  requirements: []
70
76
 
71
77
  rubyforge_project: brightbox
72
- rubygems_version: 1.2.0
78
+ rubygems_version: 1.3.1
73
79
  signing_key:
74
80
  specification_version: 2
75
81
  summary: Brightbox rails deployment scripts for Capistrano