sunshine 1.1.2 → 1.1.3.pre

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/History.txt CHANGED
@@ -1,3 +1,15 @@
1
+ === 1.1.3 / 2010-09-07
2
+
3
+ * Improvements:
4
+
5
+ * Added support for custom env/start/stop/restart scripts.
6
+
7
+ * Deploy env defaults to ENV 'DEPLOY_ENV', 'env', 'RACK_ENV', or 'RAILS_ENV'.
8
+
9
+ * Bugfixes:
10
+
11
+ * Added better extensible package manager checking to ServerApp.
12
+
1
13
  === 1.1.2 / 2010-04-15
2
14
 
3
15
  * Improvements:
data/Manifest.txt CHANGED
@@ -46,7 +46,6 @@ lib/sunshine/repos/svn_repo.rb
46
46
  lib/sunshine/server_app.rb
47
47
  lib/sunshine/shell.rb
48
48
  templates/apache/apache.conf.erb
49
- templates/logrotate/logrotate.conf.erb
50
49
  templates/mongrel_rails/mongrel_rails.conf.erb
51
50
  templates/nginx/nginx.conf.erb
52
51
  templates/nginx/nginx_optimize.conf
@@ -78,4 +77,4 @@ test/unit/test_server_cluster.rb
78
77
  test/unit/test_shell.rb
79
78
  test/unit/test_sunshine.rb
80
79
  test/unit/test_svn_repo.rb
81
- test/unit/test_unicorn.rb
80
+ test/unit/test_unicorn.rb
data/lib/sunshine.rb CHANGED
@@ -19,7 +19,7 @@ module Sunshine
19
19
 
20
20
  ##
21
21
  # Sunshine version.
22
- VERSION = '1.1.2'
22
+ VERSION = '1.1.3.pre'
23
23
 
24
24
  ##
25
25
  # Path to the list of installed sunshine apps.
@@ -38,7 +38,12 @@ module Sunshine
38
38
  DEFAULT_CONFIG = {
39
39
  'auto' => false,
40
40
  'auto_dependencies' => true,
41
- 'deploy_env' => :development,
41
+ 'deploy_env' =>
42
+ ( ENV['DEPLOY_ENV'] ||
43
+ ENV['env'] ||
44
+ ENV['RACK_ENV'] ||
45
+ ENV['RAILS_ENV'] ||
46
+ :development ),
42
47
  'level' => 'info',
43
48
  'max_deploy_versions' => 5,
44
49
  'remote_checkouts' => false,
data/lib/sunshine/app.rb CHANGED
@@ -19,15 +19,13 @@ module Sunshine
19
19
  #
20
20
  # app.deploy do |app|
21
21
  #
22
- # app_server = Sunshine::Rainbows.new(app)
23
- # app_server.restart
24
- #
25
- # Sunshine::Nginx.new(app, :point_to => app_server).setup
22
+ # app_server = Sunshine::Rainbows.new app, :port => 3000
23
+ # web_server = Sunshine::Nginx.new app, :point_to => app_server
26
24
  #
25
+ # app_server.setup
26
+ # web_server.setup
27
27
  # end
28
28
  #
29
- # app.start :force => true
30
- #
31
29
  # Multiple apps can be defined, and deployed from a single deploy script.
32
30
  # The constructor also supports passing a yaml file path:
33
31
  #
@@ -148,9 +146,9 @@ module Sunshine
148
146
  end
149
147
 
150
148
 
151
- attr_reader :name, :repo, :server_apps, :sudo
149
+ attr_reader :name, :repo, :server_apps, :sudo, :deploy_name, :deploy_env
152
150
  attr_reader :root_path, :checkout_path, :current_path, :deploys_path
153
- attr_reader :shared_path, :log_path, :deploy_name, :deploy_env
151
+ attr_reader :shared_path, :log_path, :scripts_path
154
152
  attr_accessor :remote_checkout
155
153
 
156
154
  ##
@@ -953,6 +951,7 @@ module Sunshine
953
951
  @shared_path = "#{@root_path}/shared"
954
952
  @log_path = "#{@shared_path}/log"
955
953
  @checkout_path = "#{@deploys_path}/#{@deploy_name}"
954
+ @scripts_path = "#{@checkout_path}/scripts"
956
955
  end
957
956
 
958
957
 
@@ -35,10 +35,16 @@ Sunshine.dependencies do
35
35
  ##
36
36
  # Define phusion passenger dependencies
37
37
 
38
+ apt 'openssl-devel', :pkg => 'libssl-dev'
39
+ yum 'openssl-devel'
40
+
41
+ apt 'zlib-devel', :pkg => 'zlib-dev'
42
+ yum 'zlib-devel'
43
+
38
44
  gem 'passenger', :version => ">=2.2.11"
39
45
 
40
46
  dependency 'passenger-nginx' do
41
- requires 'passenger'
47
+ requires 'passenger', 'openssl-devel', 'zlib-devel'
42
48
 
43
49
  install do |shell, sudo|
44
50
 
@@ -28,6 +28,14 @@ module Sunshine
28
28
  end
29
29
 
30
30
 
31
+ ##
32
+ # Checks if dependency type is valid for a given shell.
33
+
34
+ def self.valid? shell=nil
35
+ shell ||= Sunshine.shell
36
+ shell.call("apt-get --version") && true rescue false
37
+ end
38
+
31
39
  private
32
40
 
33
41
  def build_pkg_name pkg_name, options={}
@@ -66,6 +66,15 @@ module Sunshine
66
66
  end
67
67
 
68
68
 
69
+ ##
70
+ # Checks if dependency type is valid for a given shell.
71
+ # Defaults to false. Override in subclass.
72
+
73
+ def self.valid? shell=nil
74
+ false
75
+ end
76
+
77
+
69
78
  attr_reader :name, :pkg, :parents, :children
70
79
 
71
80
  def initialize name, options={}, &block
@@ -30,6 +30,15 @@ module Sunshine
30
30
  end
31
31
 
32
32
 
33
+ ##
34
+ # Checks if dependency type is valid for a given shell.
35
+
36
+ def self.valid? shell=nil
37
+ shell ||= Sunshine.shell
38
+ shell.call("yum --version") && true rescue false
39
+ end
40
+
41
+
33
42
  private
34
43
 
35
44
  def build_pkg_name pkg_name, options={}
data/lib/sunshine/repo.rb CHANGED
@@ -56,8 +56,6 @@ module Sunshine
56
56
 
57
57
  def self.detect path=".", shell=nil
58
58
  @@repo_types.values.each do |repo|
59
- next if Sunshine::RsyncRepo === repo
60
-
61
59
  if repo.valid? path
62
60
  info = repo.get_info path, shell
63
61
  return repo.new(info[:url], info)
@@ -77,6 +75,16 @@ module Sunshine
77
75
  end
78
76
 
79
77
 
78
+ ##
79
+ # Checks if current working directory is a valid repo.
80
+ # Defaults to false. Subclasses must override this method to enable
81
+ # auto detecting of a given scm implementation.
82
+
83
+ def self.valid?
84
+ false
85
+ end
86
+
87
+
80
88
  attr_reader :url, :scm
81
89
 
82
90
  def initialize url, options={}
@@ -76,7 +76,7 @@ module Sunshine
76
76
 
77
77
  app_attr :name, :deploy_name
78
78
  app_attr :root_path, :checkout_path, :current_path
79
- app_attr :deploys_path, :log_path, :shared_path
79
+ app_attr :deploys_path, :log_path, :shared_path, :scripts_path
80
80
 
81
81
  attr_accessor :app, :roles, :scripts, :info, :shell, :crontab, :health
82
82
  attr_writer :pkg_manager
@@ -161,11 +161,12 @@ module Sunshine
161
161
 
162
162
  def build_deploy_info_file
163
163
 
164
- deploy_info = get_deploy_info.to_yaml
164
+ deploy_info = get_deploy_info.to_yaml
165
+ info_filepath = "#{self.scripts_path}/info"
165
166
 
166
- @shell.make_file "#{self.checkout_path}/info", deploy_info
167
+ @shell.make_file info_filepath, deploy_info
167
168
 
168
- @shell.symlink "#{self.current_path}/info", "#{self.root_path}/info"
169
+ @shell.symlink info_filepath, "#{self.root_path}/info"
169
170
  end
170
171
 
171
172
 
@@ -215,7 +216,8 @@ module Sunshine
215
216
  # Does not include symlinked directories.
216
217
 
217
218
  def directories
218
- [root_path, deploys_path, shared_path, log_path, checkout_path]
219
+ [root_path, deploys_path, shared_path,
220
+ log_path, checkout_path, scripts_path]
219
221
  end
220
222
 
221
223
 
@@ -335,7 +337,9 @@ fi
335
337
 
336
338
  def pkg_manager
337
339
  @pkg_manager ||=
338
- (@shell.call("yum --version") && Yum) rescue Apt
340
+ DependencyLib.dependency_types.detect do |dt|
341
+ dt.valid? @shell
342
+ end
339
343
  end
340
344
 
341
345
 
@@ -552,16 +556,16 @@ fi
552
556
 
553
557
 
554
558
  ##
555
- # Write an executable bash script to the app's checkout dir
556
- # on the deploy server, and symlink them to the current dir.
559
+ # Write an executable bash script to the app's scripts dir
560
+ # on the deploy server, and symlink them to the root dir.
557
561
 
558
562
  def write_script name, contents
563
+ script_file = "#{self.scripts_path}/#{name}"
559
564
 
560
- @shell.make_file "#{self.checkout_path}/#{name}", contents,
561
- :flags => '--chmod=ugo=rwx'
565
+ @shell.make_file script_file, contents,
566
+ :flags => '--chmod=ugo=rwx' unless @shell.file? script_file
562
567
 
563
- @shell.symlink "#{self.current_path}/#{name}",
564
- "#{self.root_path}/#{name}"
568
+ @shell.symlink script_file, "#{self.root_path}/#{name}"
565
569
  end
566
570
 
567
571
 
@@ -583,6 +587,7 @@ fi
583
587
  @shared_path = "#{@root_path}/shared"
584
588
  @log_path = "#{@shared_path}/log"
585
589
  @checkout_path = "#{@deploys_path}/#{@deploy_name}"
590
+ @scripts_path = "#{@checkout_path}/scripts"
586
591
  end
587
592
  end
588
593
  end
@@ -61,8 +61,7 @@ module HelperMethods
61
61
  end
62
62
 
63
63
 
64
- def assert_dep_install dep_name, type=Sunshine::Yum
65
- prefered = type rescue nil
64
+ def assert_dep_install dep_name, prefered=nil
66
65
  args = [{:call => @remote_shell, :prefer => prefered}]
67
66
 
68
67
  dep = if Sunshine::Dependency === dep_name
@@ -26,7 +26,7 @@ class TestApp < Test::Unit::TestCase
26
26
  end
27
27
 
28
28
  def teardown
29
- FileUtils.rm_f @tmpdir
29
+ FileUtils.rm_rf @tmpdir
30
30
  end
31
31
 
32
32
 
@@ -194,16 +194,22 @@ class TestApp < Test::Unit::TestCase
194
194
 
195
195
 
196
196
  def test_build_control_scripts
197
- @app.add_to_script :start, "start script"
198
- @app.add_to_script :stop, "stop script"
197
+ scripts_list = %w{start stop restart custom env}
198
+
199
+ @app.server_apps.each do |sa|
200
+ sa.shell.mock :file?, :return => false
201
+ end
202
+
203
+ @app.add_to_script :start, "start script"
204
+ @app.add_to_script :stop, "stop script"
199
205
  @app.add_to_script :custom, "custom script"
200
206
 
201
207
  @app.build_control_scripts
202
208
 
203
209
  each_remote_shell do |ds|
204
210
 
205
- %w{start stop restart custom env}.each do |script|
206
- assert_rsync(/#{script}/, "#{ds.host}:#{@app.checkout_path}/#{script}")
211
+ scripts_list.each do |script|
212
+ assert_rsync(/#{script}/, "#{ds.host}:#{@app.scripts_path}/#{script}")
207
213
  end
208
214
  end
209
215
  end
@@ -213,7 +219,7 @@ class TestApp < Test::Unit::TestCase
213
219
  @app.build_deploy_info_file
214
220
 
215
221
  each_remote_shell do |ds|
216
- assert_rsync(/info/, "#{ds.host}:#{@app.checkout_path}/info")
222
+ assert_rsync(/info/, "#{ds.host}:#{@app.scripts_path}/info")
217
223
  end
218
224
  end
219
225
 
@@ -305,6 +311,8 @@ class TestApp < Test::Unit::TestCase
305
311
  check_ruby = "test \"$(yum list installed #{ruby_dep.pkg} | "+
306
312
  "grep -c #{ruby_dep.pkg})\" -ge 1"
307
313
 
314
+ set_mock_response_for @app, 1, "apt-get --version" => [:err, ""]
315
+ set_mock_response_for @app, 0, "yum --version" => [:out, "1.0"]
308
316
 
309
317
  set_mock_response_for @app, 1,
310
318
  {check_nginx => [:err, ""],
@@ -89,13 +89,15 @@ class TestServerApp < Test::Unit::TestCase
89
89
 
90
90
 
91
91
  def test_build_deploy_info_file
92
- args = ["#{@app.checkout_path}/info", @sa.get_deploy_info.to_yaml]
92
+ @sa.shell.mock :file?, :return => false
93
+
94
+ args = ["#{@app.scripts_path}/info", @sa.get_deploy_info.to_yaml]
93
95
 
94
96
  @sa.build_deploy_info_file
95
97
 
96
98
  assert @sa.shell.method_called?(:make_file, :args => args)
97
99
 
98
- args = ["#{@app.current_path}/info", "#{@app.root_path}/info"]
100
+ args = ["#{@app.scripts_path}/info", "#{@app.root_path}/info"]
99
101
 
100
102
  assert @sa.shell.method_called?(:symlink, :args => args)
101
103
  end
@@ -191,8 +193,8 @@ class TestServerApp < Test::Unit::TestCase
191
193
 
192
194
  @sa.install_deps "ruby", nginx_dep
193
195
 
194
- assert_dep_install 'ruby'
195
- assert_dep_install 'nginx'
196
+ assert_dep_install 'ruby', Sunshine::Yum
197
+ assert_dep_install 'nginx', Sunshine::Yum
196
198
  end
197
199
 
198
200
 
@@ -233,7 +235,7 @@ class TestServerApp < Test::Unit::TestCase
233
235
  def test_rake
234
236
  @sa.rake "db:migrate"
235
237
 
236
- assert_dep_install 'rake'
238
+ assert_dep_install 'rake', @sa.pkg_manager
237
239
  assert_server_call "cd #{@app.checkout_path} && rake db:migrate"
238
240
  end
239
241
 
@@ -315,7 +317,7 @@ class TestServerApp < Test::Unit::TestCase
315
317
  def test_run_bundler
316
318
  @sa.run_bundler
317
319
 
318
- assert_dep_install 'bundler'
320
+ assert_dep_install 'bundler', @sa.pkg_manager
319
321
  assert_server_call "cd #{@app.checkout_path} && gem bundle"
320
322
  end
321
323
 
@@ -323,7 +325,7 @@ class TestServerApp < Test::Unit::TestCase
323
325
  def test_run_geminstaller
324
326
  @sa.run_geminstaller
325
327
 
326
- assert_dep_install 'geminstaller'
328
+ assert_dep_install 'geminstaller', @sa.pkg_manager
327
329
  assert_server_call "cd #{@app.checkout_path} && geminstaller -e"
328
330
  end
329
331
 
@@ -333,7 +335,7 @@ class TestServerApp < Test::Unit::TestCase
333
335
 
334
336
  @sa.sass(*sass_files)
335
337
 
336
- assert_dep_install 'haml'
338
+ assert_dep_install 'haml', @sa.pkg_manager
337
339
 
338
340
  sass_files.each do |file|
339
341
  sass_file = "public/stylesheets/sass/#{file}.sass"
@@ -425,14 +427,33 @@ class TestServerApp < Test::Unit::TestCase
425
427
 
426
428
 
427
429
  def test_write_script
430
+ @sa.shell.mock :file?, :return => false
431
+
428
432
  @sa.write_script "script_name", "script contents"
429
433
 
430
- args = ["#{@app.checkout_path}/script_name",
434
+ args = ["#{@app.scripts_path}/script_name",
431
435
  "script contents", {:flags => "--chmod=ugo=rwx"}]
432
436
 
433
437
  assert @sa.shell.method_called?(:make_file, :args => args)
434
438
 
435
- args = ["#{@app.current_path}/script_name",
439
+ args = ["#{@app.scripts_path}/script_name",
440
+ "#{@app.root_path}/script_name"]
441
+
442
+ assert @sa.shell.method_called?(:symlink, :args => args)
443
+ end
444
+
445
+
446
+ def test_write_script_existing
447
+ @sa.shell.mock :file?, :return => true
448
+
449
+ @sa.write_script "script_name", "script contents"
450
+
451
+ args = ["#{@app.scripts_path}/script_name",
452
+ "script contents", {:flags => "--chmod=ugo=rwx"}]
453
+
454
+ assert !@sa.shell.method_called?(:make_file, :args => args)
455
+
456
+ args = ["#{@app.scripts_path}/script_name",
436
457
  "#{@app.root_path}/script_name"]
437
458
 
438
459
  assert @sa.shell.method_called?(:symlink, :args => args)
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sunshine
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ prerelease: true
5
5
  segments:
6
6
  - 1
7
7
  - 1
8
- - 2
9
- version: 1.1.2
8
+ - 3
9
+ - pre
10
+ version: 1.1.3.pre
10
11
  platform: ruby
11
12
  authors:
12
13
  - Jeremie Castagna
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-04-15 00:00:00 -07:00
18
+ date: 2010-09-07 00:00:00 -07:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
@@ -151,7 +152,6 @@ files:
151
152
  - lib/sunshine/server_app.rb
152
153
  - lib/sunshine/shell.rb
153
154
  - templates/apache/apache.conf.erb
154
- - templates/logrotate/logrotate.conf.erb
155
155
  - templates/mongrel_rails/mongrel_rails.conf.erb
156
156
  - templates/nginx/nginx.conf.erb
157
157
  - templates/nginx/nginx_optimize.conf
@@ -203,11 +203,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
203
203
  version: "0"
204
204
  required_rubygems_version: !ruby/object:Gem::Requirement
205
205
  requirements:
206
- - - ">="
206
+ - - ">"
207
207
  - !ruby/object:Gem::Version
208
208
  segments:
209
- - 0
210
- version: "0"
209
+ - 1
210
+ - 3
211
+ - 1
212
+ version: 1.3.1
211
213
  requirements: []
212
214
 
213
215
  rubyforge_project: sunshine
@@ -1,11 +0,0 @@
1
- <%= log_path %>/* {
2
- missingok
3
- rotate 168
4
- compress
5
- delaycompress
6
- olddir <%= log_path %>/rotate
7
- create 0666 <%= server_app.shell.user %>
8
- lastaction
9
- logpush <%= log_path %>/rotate/*
10
- endscript
11
- }