capricorn 0.2.21 → 0.2.22

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,15 +4,21 @@ module Capricorn
4
4
  module Apps # :nodoc:
5
5
 
6
6
  class Satellite < Thor
7
- desc 'list', 'show all managed satellites'
7
+ desc 'list [DOMAIN]', 'show info for managed satellites'
8
8
  method_options :token => :optional
9
- def list
10
- satellites = Capricorn.client(options[:token]).satellites
9
+ def list(domain=nil)
10
+ satellites = Capricorn.client(options[:token]).satellites.dup
11
+ satellites.sort! { |a,b| a.domain <=> b.domain }
11
12
  satellites.size.times do |i|
12
13
  sat = satellites[i]
13
- puts [sat.domain, (sat.development ? ['development:', sat.module_name] : [])].flatten.join(' ')
14
- sat.engines.each do |name, options|
15
- puts "- #{name} #{options.inspect}"
14
+ if domain.nil? or domain == sat.domain
15
+ puts [
16
+ sat.domain,
17
+ (sat.development ? ['development:', sat.module_name] : [])
18
+ ].flatten.join(' ')
19
+ sat.engines.each do |name, options|
20
+ puts "- #{name} #{options.inspect}"
21
+ end
16
22
  end
17
23
  end
18
24
  rescue => e
@@ -37,6 +43,18 @@ module Capricorn
37
43
  def relink(domain)
38
44
  Capricorn.client(options[:token]).relink_satellite(domain)
39
45
  end
46
+
47
+ desc 'update DOMAIN', 'update the installed engines of a satellite'
48
+ method_options :token => :optional
49
+ def update(domain)
50
+ Capricorn.client(options[:token]).update_satellite(domain)
51
+ end
52
+
53
+ # desc 'upgrade DOMAIN', 'upgrade/rebuild the rails app of a satellite'
54
+ # method_options :token => :optional
55
+ # def upgrade(domain)
56
+ # Capricorn.client(options[:token]).upgrade_satellite(domain)
57
+ # end
40
58
  end
41
59
 
42
60
  end
@@ -12,6 +12,24 @@ module Capricorn
12
12
  end
13
13
  end
14
14
 
15
+ def update_all_engines
16
+ @engines.each do |gem_name,options|
17
+ dep = Gem::Dependency.new(gem_name.to_s, Gem::Requirement.default)
18
+ specs = Gem::SourceIndex.from_installed_gems.search(dep)
19
+
20
+ return false if specs.empty?
21
+
22
+ specs.sort! do |a,b|
23
+ b.version <=> a.version
24
+ end
25
+
26
+ spec_version = specs.first.version.to_s
27
+ options[:version] = spec_version
28
+ end
29
+
30
+ return true
31
+ end
32
+
15
33
  def update_engine(name, options={})
16
34
  if @engines.key? name
17
35
  @engines[name] = options
@@ -65,6 +65,15 @@ module Capricorn
65
65
  end
66
66
  end
67
67
 
68
+ def update_satellite(domain)
69
+ satellite = Capricorn.system.find_satellite(domain)
70
+ if satellite
71
+ Capricorn.system.update_satellite(satellite)
72
+ else
73
+ Capricorn.log "Satellite not found (#{domain})"
74
+ end
75
+ end
76
+
68
77
  def uninstall_satellite(domain)
69
78
  satellite = Capricorn.system.find_satellite(domain)
70
79
  if satellite
@@ -14,7 +14,7 @@ module Capricorn
14
14
  end
15
15
  end
16
16
 
17
- allow :stop_server, :restart_server, :reload_server, :server_version, :update_server, :install_satellite, :uninstall_satellite, :install_engine, :update_engine, :uninstall_engine, :satellites, :queued_jobs, :cancel_job, :immediate_job, :make_development_satellite, :update_gems, :relink_satellite
17
+ allow :stop_server, :restart_server, :reload_server, :server_version, :update_server, :install_satellite, :uninstall_satellite, :install_engine, :update_engine, :uninstall_engine, :satellites, :queued_jobs, :cancel_job, :immediate_job, :make_development_satellite, :update_gems, :relink_satellite, :update_satellite
18
18
 
19
19
  class << self
20
20
  undef_method :allow
@@ -88,6 +88,23 @@ module Capricorn
88
88
  end
89
89
  end
90
90
 
91
+ def update_satellite(satellite)
92
+ if satellite
93
+ self.queue.enqueue("update #{satellite.domain}", :satellite => satellite) do |options|
94
+
95
+ satellite = options[:satellite]
96
+ if satellite.update_all_engines
97
+ run_action_on :update_engine, satellite
98
+ run_action_on :link_satellite, satellite
99
+ save_satellite! satellite
100
+ end
101
+
102
+ end
103
+ else
104
+ false
105
+ end
106
+ end
107
+
91
108
  def uninstall_satellite(satellite)
92
109
  if satellite
93
110
  self.queue.enqueue("uninstall #{satellite.domain}", :satellite => satellite) do |options|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capricorn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.21
4
+ version: 0.2.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Menke
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-20 00:00:00 +02:00
12
+ date: 2009-09-16 00:00:00 +02:00
13
13
  default_executable: capricorn
14
14
  dependencies: []
15
15