sunshine 1.1.3.pre → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +8 -2
- data/Manifest.txt +1 -0
- data/README.txt +37 -1
- data/lib/commands/default.rb +2 -0
- data/lib/commands/list.rb +1 -1
- data/lib/commands/script.rb +67 -0
- data/lib/sunshine.rb +4 -3
- data/lib/sunshine/app.rb +42 -7
- data/lib/sunshine/crontab.rb +26 -5
- data/lib/sunshine/package_managers/apt.rb +3 -3
- data/lib/sunshine/package_managers/dependency.rb +1 -1
- data/lib/sunshine/package_managers/yum.rb +2 -3
- data/lib/sunshine/remote_shell.rb +1 -1
- data/lib/sunshine/server_app.rb +30 -11
- data/lib/sunshine/shell.rb +11 -1
- data/templates/sunshine/sunshine.rake +21 -4
- data/test/unit/test_app.rb +1 -1
- data/test/unit/test_crontab.rb +14 -4
- data/test/unit/test_server_app.rb +1 -1
- metadata +45 -16
data/History.txt
CHANGED
@@ -1,15 +1,21 @@
|
|
1
|
-
=== 1.
|
1
|
+
=== 1.2.0 / 2010-09-08
|
2
2
|
|
3
3
|
* Improvements:
|
4
4
|
|
5
|
-
* Added support for custom env/start/stop/restart scripts.
|
5
|
+
* Added better support for custom env/start/stop/restart scripts.
|
6
|
+
|
7
|
+
* Added scripts sunshine command to call custom scripts remotely.
|
6
8
|
|
7
9
|
* Deploy env defaults to ENV 'DEPLOY_ENV', 'env', 'RACK_ENV', or 'RAILS_ENV'.
|
8
10
|
|
9
11
|
* Bugfixes:
|
10
12
|
|
13
|
+
* ServerApp#run_geminstaller no longer defaults to using sudo.
|
14
|
+
|
11
15
|
* Added better extensible package manager checking to ServerApp.
|
12
16
|
|
17
|
+
* Fixed Cronjob functionality and added array support.
|
18
|
+
|
13
19
|
=== 1.1.2 / 2010-04-15
|
14
20
|
|
15
21
|
* Improvements:
|
data/Manifest.txt
CHANGED
data/README.txt
CHANGED
@@ -554,7 +554,8 @@ The Sunshine commands are as follows:
|
|
554
554
|
list Display deployed apps
|
555
555
|
restart Restart a deployed app
|
556
556
|
rm Unregister an app with sunshine
|
557
|
-
run Run a Sunshine
|
557
|
+
run Run a Sunshine ruby file
|
558
|
+
script Run an app script
|
558
559
|
start Start a deployed app
|
559
560
|
stop Stop a deployed app
|
560
561
|
|
@@ -562,6 +563,41 @@ For more help on sunshine commands, use 'sunshine COMMAND --help'.
|
|
562
563
|
For more information about control scripts, see the
|
563
564
|
Sunshine::App#build_control_scripts method.
|
564
565
|
|
566
|
+
=== Remote Scripts and Permissions:
|
567
|
+
|
568
|
+
Important:
|
569
|
+
|
570
|
+
Applications are deployed on a per-user basis. When calling
|
571
|
+
commands that require superuser permissions (e.g. calling restart on an
|
572
|
+
app that runs on Apache, port 80), make sure that the user used to log in
|
573
|
+
has sudo permissions.
|
574
|
+
|
575
|
+
Example:
|
576
|
+
|
577
|
+
I've deployed an application logged in as 'superuser' but for a
|
578
|
+
'peon' user with a lower permission level using something like:
|
579
|
+
Sunshine.setup 'sudo' => 'peon'
|
580
|
+
@app = Sunshine::App.new :remote_shells => 'superuser@myserver.com'
|
581
|
+
|
582
|
+
Using any of the following will fail to return since 'peon' has
|
583
|
+
no sudo priviledges:
|
584
|
+
$ sunshine restart app -r peon@myserver.com
|
585
|
+
$ sunshine restart app -r peon@myserver.com -S
|
586
|
+
|
587
|
+
Yet, if you only log in as 'superuser' the app will not be found as it will
|
588
|
+
be looking for apps deployed and run for 'superuser', hence this is wrong too:
|
589
|
+
$ sunshine restart app -r superuser@myserver.com
|
590
|
+
|
591
|
+
To run the script correctly, use the same setup used for your deploy,
|
592
|
+
in this case:
|
593
|
+
$ sunshine restart app -r superuser@myserver.com -S peon
|
594
|
+
|
595
|
+
This is true for the following commands:
|
596
|
+
$ sunshine list --status
|
597
|
+
$ sunshine restart
|
598
|
+
$ sunshine script
|
599
|
+
$ sunshine start
|
600
|
+
$ sunshine stop
|
565
601
|
|
566
602
|
== Licence
|
567
603
|
|
data/lib/commands/default.rb
CHANGED
@@ -101,6 +101,8 @@ Sunshine is an object oriented deploy tool for rack applications.
|
|
101
101
|
list Display deployed apps
|
102
102
|
restart Restart a deployed app
|
103
103
|
rm Unregister an app with #{opt.program_name}
|
104
|
+
run Run a Sunshine ruby file
|
105
|
+
script Run an app script
|
104
106
|
start Start a deployed app
|
105
107
|
stop Stop a deployed app
|
106
108
|
|
data/lib/commands/list.rb
CHANGED
@@ -0,0 +1,67 @@
|
|
1
|
+
module Sunshine
|
2
|
+
|
3
|
+
##
|
4
|
+
# Runs a given script of all specified sunshine apps.
|
5
|
+
#
|
6
|
+
# Usage: sunshine script script_name [options] app_name [more names...]
|
7
|
+
#
|
8
|
+
# Arguments:
|
9
|
+
# script_name Name of the script to run.
|
10
|
+
# app_name Name of the application to run script for.
|
11
|
+
#
|
12
|
+
# Options:
|
13
|
+
# -f, --format FORMAT Set the output format (txt, yml, json)
|
14
|
+
# -u, --user USER User to use for remote login. Use with -r.
|
15
|
+
# -r, --remote svr1,svr2 Run on one or more remote servers.
|
16
|
+
# -v, --verbose Run in verbose mode.
|
17
|
+
|
18
|
+
class ScriptCommand < ListCommand
|
19
|
+
|
20
|
+
##
|
21
|
+
# Takes an array and a hash, runs the command and returns:
|
22
|
+
# true: success
|
23
|
+
# false: failed
|
24
|
+
# exitcode:
|
25
|
+
# code == 0: success
|
26
|
+
# code != 0: failed
|
27
|
+
# and optionally an accompanying message.
|
28
|
+
|
29
|
+
def self.exec names, config
|
30
|
+
script_name = names.delete_at(0)
|
31
|
+
|
32
|
+
output = exec_each_server config do |shell|
|
33
|
+
new(shell).script(script_name, names)
|
34
|
+
end
|
35
|
+
|
36
|
+
return output
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
##
|
41
|
+
# Run specified script for apps.
|
42
|
+
|
43
|
+
def script name, app_names
|
44
|
+
each_app(*app_names) do |server_app|
|
45
|
+
server_app.run_script name
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
##
|
51
|
+
# Parses the argv passed to the command
|
52
|
+
|
53
|
+
def self.parse_args argv
|
54
|
+
parse_remote_args(argv) do |opt, options|
|
55
|
+
opt.banner = <<-EOF
|
56
|
+
|
57
|
+
Usage: #{opt.program_name} script script_name [options] app_name [more names...]
|
58
|
+
|
59
|
+
Arguments:
|
60
|
+
script_name Name of the script to run.
|
61
|
+
app_name Name of the application to run script for.
|
62
|
+
EOF
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
data/lib/sunshine.rb
CHANGED
@@ -19,7 +19,7 @@ module Sunshine
|
|
19
19
|
|
20
20
|
##
|
21
21
|
# Sunshine version.
|
22
|
-
VERSION = '1.
|
22
|
+
VERSION = '1.2.0'
|
23
23
|
|
24
24
|
##
|
25
25
|
# Path to the list of installed sunshine apps.
|
@@ -27,7 +27,7 @@ module Sunshine
|
|
27
27
|
|
28
28
|
##
|
29
29
|
# Commands supported by Sunshine.
|
30
|
-
COMMANDS = %w{add list restart rm run start stop}
|
30
|
+
COMMANDS = %w{add list restart rm run script start stop}
|
31
31
|
|
32
32
|
##
|
33
33
|
# File DATA from Sunshine run files.
|
@@ -48,7 +48,7 @@ module Sunshine
|
|
48
48
|
'max_deploy_versions' => 5,
|
49
49
|
'remote_checkouts' => false,
|
50
50
|
'timeout' => 300,
|
51
|
-
'web_directory' => '/
|
51
|
+
'web_directory' => '/srv/http'
|
52
52
|
}
|
53
53
|
|
54
54
|
##
|
@@ -413,6 +413,7 @@ module Sunshine
|
|
413
413
|
require 'commands/run'
|
414
414
|
require 'commands/restart'
|
415
415
|
require 'commands/rm'
|
416
|
+
require 'commands/script'
|
416
417
|
require 'commands/start'
|
417
418
|
require 'commands/stop'
|
418
419
|
end
|
data/lib/sunshine/app.rb
CHANGED
@@ -254,6 +254,7 @@ module Sunshine
|
|
254
254
|
# run App#start.
|
255
255
|
|
256
256
|
def deploy options=nil
|
257
|
+
success = false
|
257
258
|
prev_connection = connected?
|
258
259
|
|
259
260
|
deploy_trap = Sunshine.add_trap "Reverting deploy of #{@name}" do
|
@@ -285,9 +286,11 @@ module Sunshine
|
|
285
286
|
build_crontab
|
286
287
|
|
287
288
|
register_as_deployed
|
288
|
-
remove_old_deploys
|
289
289
|
|
290
|
-
start :force => true
|
290
|
+
success = start :force => true
|
291
|
+
|
292
|
+
remove_old_deploys
|
293
|
+
success &&= deployed?
|
291
294
|
end
|
292
295
|
end
|
293
296
|
|
@@ -300,11 +303,13 @@ module Sunshine
|
|
300
303
|
Sunshine.logger.error '>>', e.backtrace.join("\n")
|
301
304
|
revert! options
|
302
305
|
start options
|
303
|
-
disconnect options unless prev_connection
|
304
306
|
end
|
305
307
|
|
306
308
|
ensure
|
309
|
+
disconnect options unless prev_connection
|
307
310
|
Sunshine.delete_trap deploy_trap
|
311
|
+
|
312
|
+
success
|
308
313
|
end
|
309
314
|
|
310
315
|
|
@@ -333,8 +338,25 @@ module Sunshine
|
|
333
338
|
##
|
334
339
|
# Add a command to the crontab to be generated remotely:
|
335
340
|
# add_to_crontab "reboot", "@reboot /path/to/app/start", :role => :web
|
341
|
+
#
|
342
|
+
# Note: This method will append jobs to already existing cron jobs for this
|
343
|
+
# application and job name, including previous deploys.
|
336
344
|
|
337
345
|
def add_to_crontab name, cronjob, options=nil
|
346
|
+
with_server_apps options do |server_app|
|
347
|
+
server_app.crontab[name] << cronjob
|
348
|
+
end
|
349
|
+
end
|
350
|
+
|
351
|
+
|
352
|
+
##
|
353
|
+
# Add a command to the crontab to be generated remotely:
|
354
|
+
# cronjob "reboot", "@reboot /path/to/app/start", :role => :web
|
355
|
+
#
|
356
|
+
# Note: This method will override already existing cron jobs for this
|
357
|
+
# application and job name, including previous deploys.
|
358
|
+
|
359
|
+
def cronjob name, cronjob, options=nil
|
338
360
|
with_server_apps options do |server_app|
|
339
361
|
server_app.crontab[name] = cronjob
|
340
362
|
end
|
@@ -458,7 +480,8 @@ module Sunshine
|
|
458
480
|
# Check if app has been deployed successfully.
|
459
481
|
|
460
482
|
def deployed? options=nil
|
461
|
-
with_server_apps options,
|
483
|
+
with_server_apps options,
|
484
|
+
:msg => "Checking deploy", :no_threads => true do |server_app|
|
462
485
|
return false unless server_app.deployed?
|
463
486
|
end
|
464
487
|
|
@@ -675,7 +698,7 @@ module Sunshine
|
|
675
698
|
def run_bundler options=nil
|
676
699
|
with_server_apps options,
|
677
700
|
:msg => "Running Bundler",
|
678
|
-
:send => :run_bundler
|
701
|
+
:send => [:run_bundler, options]
|
679
702
|
|
680
703
|
rescue => e
|
681
704
|
raise CriticalDeployError, e
|
@@ -688,7 +711,7 @@ module Sunshine
|
|
688
711
|
def run_geminstaller options=nil
|
689
712
|
with_server_apps options,
|
690
713
|
:msg => "Running GemInstaller",
|
691
|
-
:send => :run_geminstaller
|
714
|
+
:send => [:run_geminstaller, options]
|
692
715
|
|
693
716
|
rescue => e
|
694
717
|
raise CriticalDeployError, e
|
@@ -706,6 +729,18 @@ module Sunshine
|
|
706
729
|
end
|
707
730
|
|
708
731
|
|
732
|
+
##
|
733
|
+
# Run the given script of a deployed app on the specified
|
734
|
+
# deploy servers.
|
735
|
+
# Post-deploy only.
|
736
|
+
|
737
|
+
def run_script name, options=nil
|
738
|
+
with_server_apps options,
|
739
|
+
:msg => "Running #{name} script",
|
740
|
+
:send => [:run_script, name, options]
|
741
|
+
end
|
742
|
+
|
743
|
+
|
709
744
|
##
|
710
745
|
# Run a sass task on any or all deploy servers.
|
711
746
|
|
@@ -951,7 +986,7 @@ module Sunshine
|
|
951
986
|
@shared_path = "#{@root_path}/shared"
|
952
987
|
@log_path = "#{@shared_path}/log"
|
953
988
|
@checkout_path = "#{@deploys_path}/#{@deploy_name}"
|
954
|
-
@scripts_path = "#{@checkout_path}/
|
989
|
+
@scripts_path = "#{@checkout_path}/sunshine_scripts"
|
955
990
|
end
|
956
991
|
|
957
992
|
|
data/lib/sunshine/crontab.rb
CHANGED
@@ -15,6 +15,24 @@ module Sunshine
|
|
15
15
|
end
|
16
16
|
|
17
17
|
|
18
|
+
##
|
19
|
+
# Access the jobs hash. Equivalent to:
|
20
|
+
# crontab.jobs[key]
|
21
|
+
|
22
|
+
def [] key
|
23
|
+
self.jobs[key]
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
##
|
28
|
+
# Set a value in the jobs hash.Equivalent to:
|
29
|
+
# crontab.jobs[key] = value
|
30
|
+
|
31
|
+
def []= key, value
|
32
|
+
self.jobs[key] = value
|
33
|
+
end
|
34
|
+
|
35
|
+
|
18
36
|
##
|
19
37
|
# Get the jobs matching this crontab. Loads them from the crontab
|
20
38
|
# if @jobs hasn't been set yet.
|
@@ -31,7 +49,10 @@ module Sunshine
|
|
31
49
|
crontab.strip!
|
32
50
|
|
33
51
|
jobs.each do |namespace, cron_job|
|
34
|
-
|
52
|
+
cron_job = cron_job.join("\n") if Array === cron_job
|
53
|
+
crontab = delete_jobs crontab, namespace
|
54
|
+
|
55
|
+
next if cron_job.nil? || cron_job.empty?
|
35
56
|
|
36
57
|
start_id, end_id = get_job_ids namespace
|
37
58
|
cron_str = "\n#{start_id}\n#{cron_job.chomp}\n#{end_id}\n\n"
|
@@ -85,7 +106,7 @@ module Sunshine
|
|
85
106
|
# Returns a hash of namespace/jobs pairs.
|
86
107
|
|
87
108
|
def parse string
|
88
|
-
jobs = Hash.new
|
109
|
+
jobs = Hash.new{|hash, key| hash[key] = Array.new}
|
89
110
|
|
90
111
|
namespace = nil
|
91
112
|
|
@@ -98,12 +119,12 @@ module Sunshine
|
|
98
119
|
end
|
99
120
|
|
100
121
|
if namespace
|
101
|
-
|
102
|
-
jobs[namespace] << line
|
122
|
+
line = line.strip
|
123
|
+
jobs[namespace] << line unless line.empty?
|
103
124
|
end
|
104
125
|
end
|
105
126
|
|
106
|
-
jobs
|
127
|
+
jobs unless jobs.empty?
|
107
128
|
end
|
108
129
|
|
109
130
|
|
@@ -31,11 +31,11 @@ module Sunshine
|
|
31
31
|
##
|
32
32
|
# Checks if dependency type is valid for a given shell.
|
33
33
|
|
34
|
-
def self.
|
35
|
-
shell
|
36
|
-
shell.call("apt-get --version") && true rescue false
|
34
|
+
def self.system_manager? shell=nil
|
35
|
+
(shell || Sunshine.shell).syscall "apt-get --version"
|
37
36
|
end
|
38
37
|
|
38
|
+
|
39
39
|
private
|
40
40
|
|
41
41
|
def build_pkg_name pkg_name, options={}
|
@@ -33,9 +33,8 @@ module Sunshine
|
|
33
33
|
##
|
34
34
|
# Checks if dependency type is valid for a given shell.
|
35
35
|
|
36
|
-
def self.
|
37
|
-
shell
|
38
|
-
shell.call("yum --version") && true rescue false
|
36
|
+
def self.system_manager? shell=nil
|
37
|
+
(shell || Sunshine.shell).syscall "yum --version"
|
39
38
|
end
|
40
39
|
|
41
40
|
|
data/lib/sunshine/server_app.rb
CHANGED
@@ -127,6 +127,7 @@ module Sunshine
|
|
127
127
|
# To add to, or define a control script, see App#add_to_script.
|
128
128
|
|
129
129
|
def build_control_scripts
|
130
|
+
@shell.call "mkdir -p #{self.scripts_path}"
|
130
131
|
|
131
132
|
write_script "env", make_env_bash_script
|
132
133
|
|
@@ -193,7 +194,11 @@ module Sunshine
|
|
193
194
|
def deploy_details reload=false
|
194
195
|
return @deploy_details if @deploy_details && !reload
|
195
196
|
@deploy_details =
|
196
|
-
YAML.load @shell.call("cat #{self.
|
197
|
+
YAML.load @shell.call("cat #{self.scripts_path}/info") rescue nil
|
198
|
+
|
199
|
+
@deploy_details = nil unless Hash === @deploy_details
|
200
|
+
|
201
|
+
@deploy_details
|
197
202
|
end
|
198
203
|
|
199
204
|
|
@@ -338,7 +343,7 @@ fi
|
|
338
343
|
def pkg_manager
|
339
344
|
@pkg_manager ||=
|
340
345
|
DependencyLib.dependency_types.detect do |dt|
|
341
|
-
dt.
|
346
|
+
dt.system_manager? @shell
|
342
347
|
end
|
343
348
|
end
|
344
349
|
|
@@ -412,20 +417,34 @@ fi
|
|
412
417
|
##
|
413
418
|
# Runs bundler. Installs the bundler gem if missing.
|
414
419
|
|
415
|
-
def run_bundler
|
420
|
+
def run_bundler options={}
|
416
421
|
install_deps 'bundler', :type => Gem
|
417
|
-
@shell.call "cd #{self.checkout_path} && gem bundle"
|
422
|
+
@shell.call "cd #{self.checkout_path} && gem bundle", options
|
418
423
|
end
|
419
424
|
|
420
425
|
|
421
426
|
##
|
422
427
|
# Runs geminstaller. :(
|
423
|
-
# Deprecated:
|
428
|
+
# Deprecated: how about trying bundler or isolate?
|
429
|
+
# If sudo is required to install to your GEM_HOME, make sure to
|
430
|
+
# pass it as an argument:
|
431
|
+
# server_app.run_geminstaller :sudo => true
|
424
432
|
|
425
|
-
def run_geminstaller
|
433
|
+
def run_geminstaller options={}
|
426
434
|
install_deps 'geminstaller', :type => Gem
|
427
435
|
# Without sudo gems get installed to ~user/.gems
|
428
|
-
@shell.call "cd #{self.checkout_path} && geminstaller -e",
|
436
|
+
@shell.call "cd #{self.checkout_path} && geminstaller -e", options
|
437
|
+
end
|
438
|
+
|
439
|
+
|
440
|
+
##
|
441
|
+
# Runs a script from the script_path.
|
442
|
+
# Post-deploy only.
|
443
|
+
|
444
|
+
def run_script name, options=nil, &block
|
445
|
+
options ||= {}
|
446
|
+
@shell.call \
|
447
|
+
File.join(self.scripts_path, name.to_s), options, &block rescue false
|
429
448
|
end
|
430
449
|
|
431
450
|
|
@@ -435,7 +454,7 @@ fi
|
|
435
454
|
|
436
455
|
def running?
|
437
456
|
# Permissions are handled by the script, use: :sudo => false
|
438
|
-
|
457
|
+
run_script :status, :sudo => false
|
439
458
|
end
|
440
459
|
|
441
460
|
|
@@ -476,7 +495,7 @@ fi
|
|
476
495
|
end
|
477
496
|
|
478
497
|
# Permissions are handled by the script, use: :sudo => false
|
479
|
-
|
498
|
+
run_script :start, :sudo => false
|
480
499
|
end
|
481
500
|
|
482
501
|
|
@@ -494,7 +513,7 @@ fi
|
|
494
513
|
|
495
514
|
def stop
|
496
515
|
# Permissions are handled by the script, use: :sudo => false
|
497
|
-
|
516
|
+
run_script :stop, :sudo => false
|
498
517
|
end
|
499
518
|
|
500
519
|
|
@@ -587,7 +606,7 @@ fi
|
|
587
606
|
@shared_path = "#{@root_path}/shared"
|
588
607
|
@log_path = "#{@shared_path}/log"
|
589
608
|
@checkout_path = "#{@deploys_path}/#{@deploy_name}"
|
590
|
-
@scripts_path = "#{@checkout_path}/
|
609
|
+
@scripts_path = "#{@checkout_path}/sunshine_scripts"
|
591
610
|
end
|
592
611
|
end
|
593
612
|
end
|
data/lib/sunshine/shell.rb
CHANGED
@@ -67,7 +67,9 @@ module Sunshine
|
|
67
67
|
# Execute a command on the local system and return the output.
|
68
68
|
|
69
69
|
def call cmd, options={}, &block
|
70
|
-
|
70
|
+
Sunshine.logger.info @host, "Running: #{cmd}" do
|
71
|
+
execute sudo_cmd(cmd, options), &block
|
72
|
+
end
|
71
73
|
end
|
72
74
|
|
73
75
|
|
@@ -232,6 +234,14 @@ module Sunshine
|
|
232
234
|
end
|
233
235
|
|
234
236
|
|
237
|
+
##
|
238
|
+
# Returns true if command was run successfully, otherwise returns false.
|
239
|
+
|
240
|
+
def syscall cmd, options=nil
|
241
|
+
call(cmd, options) && true rescue false
|
242
|
+
end
|
243
|
+
|
244
|
+
|
235
245
|
##
|
236
246
|
# Checks if timeout occurred.
|
237
247
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
namespace :sunshine do
|
2
2
|
|
3
3
|
##
|
4
|
-
# If using
|
4
|
+
# If using Rails, have the environment available by updating :app task to:
|
5
5
|
# task :app => :environment do
|
6
6
|
# ...
|
7
7
|
# end
|
@@ -10,9 +10,11 @@ namespace :sunshine do
|
|
10
10
|
task :app do
|
11
11
|
require 'sunshine'
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
# By default, Sunshine will deploy with env set from (in order):
|
14
|
+
# ENV['DEPLOY_ENV'] || ENV['env'] || ENV['RACK_ENV'] || ENV['RAILS_ENV']
|
15
|
+
#
|
16
|
+
# If using Rails, you may want to setup Sunshine with the same environment:
|
17
|
+
# Sunshine.setup 'deploy_env' => Rails.environment
|
16
18
|
|
17
19
|
|
18
20
|
# View the Sunshine README, scripts in the sunshine/examples
|
@@ -25,6 +27,9 @@ namespace :sunshine do
|
|
25
27
|
end
|
26
28
|
|
27
29
|
|
30
|
+
##
|
31
|
+
# Put your deploy-specific logic in the deploy task...
|
32
|
+
|
28
33
|
desc "Deploy the app"
|
29
34
|
task :deploy => :app do
|
30
35
|
Sunshine.setup 'trace' => true
|
@@ -43,6 +48,18 @@ namespace :sunshine do
|
|
43
48
|
end
|
44
49
|
|
45
50
|
|
51
|
+
##
|
52
|
+
# Server setup logic that doesn't need to be run on every deploy
|
53
|
+
# can be put in the :setup task.
|
54
|
+
#
|
55
|
+
# Note: By default, Sunshine will attempt to install missing server
|
56
|
+
# dependencies that it uses if they are not present (e.g. Nginx, Apache...).
|
57
|
+
# If you would like to disable this behavior and handle these dependencies
|
58
|
+
# explicitely, add this setup configuration to your :app or :deploy task:
|
59
|
+
# Sunshine.setup 'auto_dependencies' => false
|
60
|
+
#
|
61
|
+
# If you do so, ensure that the dependency bins are available in $PATH.
|
62
|
+
|
46
63
|
desc "Sets up deploy servers"
|
47
64
|
task :setup => :app do
|
48
65
|
Sunshine.setup 'trace' => true
|
data/test/unit/test_app.rb
CHANGED
@@ -279,7 +279,7 @@ class TestApp < Test::Unit::TestCase
|
|
279
279
|
|
280
280
|
def test_deployed?
|
281
281
|
set_mock_response_for @app, 0,
|
282
|
-
"cat #{@app.
|
282
|
+
"cat #{@app.scripts_path}/info" => [:out,
|
283
283
|
"---\n:deploy_name: '#{@app.deploy_name}'"]
|
284
284
|
|
285
285
|
deployed = @app.deployed?
|
data/test/unit/test_crontab.rb
CHANGED
@@ -37,9 +37,9 @@ job for otherapp
|
|
37
37
|
|
38
38
|
def test_parse
|
39
39
|
jobs = @cron.parse @crontab_str
|
40
|
-
assert_equal "this job should stay
|
41
|
-
assert_equal "job2 part 1
|
42
|
-
assert jobs['blah'].
|
40
|
+
assert_equal ["this job should stay"], jobs['job1']
|
41
|
+
assert_equal ["job2 part 1","job2 part 2"], jobs['job2']
|
42
|
+
assert jobs['blah'].empty?
|
43
43
|
end
|
44
44
|
|
45
45
|
|
@@ -76,6 +76,7 @@ job for otherapp
|
|
76
76
|
def test_write!
|
77
77
|
@cron.jobs["job2"] << "new job2"
|
78
78
|
@cron.jobs["job3"] = "new job3"
|
79
|
+
@cron.jobs["invalid"] = nil
|
79
80
|
|
80
81
|
@shell.set_mock_response 0, "crontab -l" => [:out, @crontab_str]
|
81
82
|
|
@@ -84,6 +85,7 @@ job for otherapp
|
|
84
85
|
assert_cronjob "job1", "this job should stay"
|
85
86
|
assert_cronjob "job2", "job2 part 1\njob2 part 2\nnew job2"
|
86
87
|
assert_cronjob "job3", "new job3"
|
88
|
+
assert_not_cronjob "invalid"
|
87
89
|
|
88
90
|
assert_cronjob "blah", "otherapp blah job", @othercron
|
89
91
|
assert_cronjob "job1", "job for otherapp", @othercron
|
@@ -118,10 +120,18 @@ job for otherapp
|
|
118
120
|
end
|
119
121
|
|
120
122
|
|
123
|
+
def assert_not_cronjob namespace, crontab=@cron
|
124
|
+
job = cronjob(namespace, [], crontab).split("\n")
|
125
|
+
assert !@crontab_str.include?(job[0])
|
126
|
+
end
|
127
|
+
|
128
|
+
|
121
129
|
def cronjob namespace, job, crontab
|
130
|
+
job = job.join("\n") if Array === job
|
131
|
+
|
122
132
|
<<-STR
|
123
133
|
# sunshine #{crontab.name}:#{namespace}:begin
|
124
|
-
#{job}
|
134
|
+
#{ job }
|
125
135
|
# sunshine #{crontab.name}:#{namespace}:end
|
126
136
|
STR
|
127
137
|
end
|
@@ -119,7 +119,7 @@ class TestServerApp < Test::Unit::TestCase
|
|
119
119
|
deploy_details = {:item => "thing"}
|
120
120
|
other_details = {:key => "value"}
|
121
121
|
|
122
|
-
@sa.shell.mock :call, :args => ["cat #{@sa.
|
122
|
+
@sa.shell.mock :call, :args => ["cat #{@sa.scripts_path}/info"],
|
123
123
|
:return => other_details.to_yaml
|
124
124
|
|
125
125
|
@sa.instance_variable_set "@deploy_details", deploy_details
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sunshine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 31
|
5
|
+
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 1
|
7
|
-
-
|
8
|
-
-
|
9
|
-
|
10
|
-
version: 1.1.3.pre
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 1.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jeremie Castagna
|
@@ -15,16 +15,18 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-09-
|
18
|
+
date: 2010-09-09 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: open4
|
23
23
|
prerelease: false
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
25
26
|
requirements:
|
26
27
|
- - ">="
|
27
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 21
|
28
30
|
segments:
|
29
31
|
- 1
|
30
32
|
- 0
|
@@ -36,9 +38,11 @@ dependencies:
|
|
36
38
|
name: rainbow
|
37
39
|
prerelease: false
|
38
40
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
39
42
|
requirements:
|
40
43
|
- - ">="
|
41
44
|
- !ruby/object:Gem::Version
|
45
|
+
hash: 31
|
42
46
|
segments:
|
43
47
|
- 1
|
44
48
|
- 0
|
@@ -50,9 +54,11 @@ dependencies:
|
|
50
54
|
name: highline
|
51
55
|
prerelease: false
|
52
56
|
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
53
58
|
requirements:
|
54
59
|
- - ">="
|
55
60
|
- !ruby/object:Gem::Version
|
61
|
+
hash: 1
|
56
62
|
segments:
|
57
63
|
- 1
|
58
64
|
- 5
|
@@ -64,9 +70,11 @@ dependencies:
|
|
64
70
|
name: json
|
65
71
|
prerelease: false
|
66
72
|
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
67
74
|
requirements:
|
68
75
|
- - ">="
|
69
76
|
- !ruby/object:Gem::Version
|
77
|
+
hash: 31
|
70
78
|
segments:
|
71
79
|
- 1
|
72
80
|
- 2
|
@@ -75,19 +83,37 @@ dependencies:
|
|
75
83
|
type: :runtime
|
76
84
|
version_requirements: *id004
|
77
85
|
- !ruby/object:Gem::Dependency
|
78
|
-
name:
|
86
|
+
name: rubyforge
|
79
87
|
prerelease: false
|
80
88
|
requirement: &id005 !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
81
90
|
requirements:
|
82
91
|
- - ">="
|
83
92
|
- !ruby/object:Gem::Version
|
93
|
+
hash: 7
|
84
94
|
segments:
|
85
95
|
- 2
|
86
|
-
-
|
87
|
-
-
|
88
|
-
version: 2.
|
96
|
+
- 0
|
97
|
+
- 4
|
98
|
+
version: 2.0.4
|
89
99
|
type: :development
|
90
100
|
version_requirements: *id005
|
101
|
+
- !ruby/object:Gem::Dependency
|
102
|
+
name: hoe
|
103
|
+
prerelease: false
|
104
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
hash: 21
|
110
|
+
segments:
|
111
|
+
- 2
|
112
|
+
- 6
|
113
|
+
- 1
|
114
|
+
version: 2.6.1
|
115
|
+
type: :development
|
116
|
+
version_requirements: *id006
|
91
117
|
description: |-
|
92
118
|
Sunshine is a framework for rack and rails application deployment.
|
93
119
|
|
@@ -118,6 +144,7 @@ files:
|
|
118
144
|
- lib/commands/restart.rb
|
119
145
|
- lib/commands/rm.rb
|
120
146
|
- lib/commands/run.rb
|
147
|
+
- lib/commands/script.rb
|
121
148
|
- lib/commands/start.rb
|
122
149
|
- lib/commands/stop.rb
|
123
150
|
- lib/sunshine.rb
|
@@ -195,25 +222,27 @@ rdoc_options:
|
|
195
222
|
require_paths:
|
196
223
|
- lib
|
197
224
|
required_ruby_version: !ruby/object:Gem::Requirement
|
225
|
+
none: false
|
198
226
|
requirements:
|
199
227
|
- - ">="
|
200
228
|
- !ruby/object:Gem::Version
|
229
|
+
hash: 3
|
201
230
|
segments:
|
202
231
|
- 0
|
203
232
|
version: "0"
|
204
233
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
234
|
+
none: false
|
205
235
|
requirements:
|
206
|
-
- - "
|
236
|
+
- - ">="
|
207
237
|
- !ruby/object:Gem::Version
|
238
|
+
hash: 3
|
208
239
|
segments:
|
209
|
-
-
|
210
|
-
|
211
|
-
- 1
|
212
|
-
version: 1.3.1
|
240
|
+
- 0
|
241
|
+
version: "0"
|
213
242
|
requirements: []
|
214
243
|
|
215
244
|
rubyforge_project: sunshine
|
216
|
-
rubygems_version: 1.3.
|
245
|
+
rubygems_version: 1.3.7
|
217
246
|
signing_key:
|
218
247
|
specification_version: 3
|
219
248
|
summary: Sunshine is a framework for rack and rails application deployment
|