Class: Capricorn::Server

Inherits:
Daemon::Base show all
Includes:
Daemon, Security, DRbUndumped
Defined in:
lib/capricorn/server.rb,
lib/capricorn/server/proxy.rb,
lib/capricorn/server/daemon.rb,
lib/capricorn/server/security.rb

Overview

the Server is supposed to be a simple DRb interface to the System.

Defined Under Namespace

Modules: Daemon, Security Classes: Proxy

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Security

included

Methods included from Daemon

included

Methods inherited from Daemon::Base

daemonize

Class Method Details

.proxyObject



19
20
21
# File 'lib/capricorn/server.rb', line 19

def self.proxy
  @proxy ||= Capricorn::Server::Proxy.new(self.shared)
end

.sharedObject



15
16
17
# File 'lib/capricorn/server.rb', line 15

def self.shared
  @shared ||= new
end

Instance Method Details

#cancel_job(id) ⇒ Object



135
136
137
# File 'lib/capricorn/server.rb', line 135

def cancel_job(id)
  Capricorn.system.queue.cancel(id)
end

#immediate_job(id) ⇒ Object



139
140
141
# File 'lib/capricorn/server.rb', line 139

def immediate_job(id)
  Capricorn.system.queue.immediate(id)
end

#install_engine(domain, name, options, immediate) ⇒ Object



95
96
97
98
99
100
101
102
# File 'lib/capricorn/server.rb', line 95

def install_engine(domain, name, options, immediate)
  satellite = Capricorn.system.find_satellite(domain)
  if satellite
    Capricorn.system.install_engine(satellite, name, options, immediate)
  else
    Capricorn.log "Satellite not found (#{domain})"
  end
end

#install_satellite(domain, immediate) ⇒ Object



55
56
57
# File 'lib/capricorn/server.rb', line 55

def install_satellite(domain, immediate)
  Capricorn.system.install_satellite(domain, immediate)
end

#make_development_satellite(domain, name) ⇒ Object



86
87
88
89
90
91
92
93
# File 'lib/capricorn/server.rb', line 86

def make_development_satellite(domain, name)
  satellite = Capricorn.system.find_satellite(domain)
  if satellite
    Capricorn.system.make_development_satellite(satellite, name)
  else
    Capricorn.log "Satellite not found (#{domain})"
  end
end

#queued_jobsObject



126
127
128
129
130
131
132
133
# File 'lib/capricorn/server.rb', line 126

def queued_jobs
  queued_jobs = []
  Capricorn.system.queue.each do |job, canceled, immediated|
    job_delay = job.delay
    queued_jobs.push([job.id, job.name, canceled, immediated, job.running?, job.waiting?, job_delay])
  end
  queued_jobs
end


59
60
61
62
63
64
65
66
# File 'lib/capricorn/server.rb', line 59

def relink_satellite(domain, immediate)
  satellite = Capricorn.system.find_satellite(domain)
  if satellite
    Capricorn.system.relink_satellite(satellite, immediate)
  else
    Capricorn.log "Satellite not found (#{domain})"
  end
end

#reload_serverObject



35
36
37
38
39
# File 'lib/capricorn/server.rb', line 35

def reload_server
  Capricorn.log "reloading the server..."
  $exitstatus = Capricorn::RELOAD_STATUS
  DRb.stop_service
end

#restart_serverObject



29
30
31
32
33
# File 'lib/capricorn/server.rb', line 29

def restart_server
  Capricorn.log "restarting the server..."
  $exitstatus = Capricorn::RESTART_STATUS
  DRb.stop_service
end

#satellitesObject



122
123
124
# File 'lib/capricorn/server.rb', line 122

def satellites
  Capricorn.system.satellites
end

#server_versionObject



41
42
43
# File 'lib/capricorn/server.rb', line 41

def server_version
  Capricorn.version
end

#stop_serverObject



23
24
25
26
27
# File 'lib/capricorn/server.rb', line 23

def stop_server
  Capricorn.log "stopping the server..."
  $exitstatus = Capricorn::STOP_STATUS
  DRb.stop_service
end

#uninstall_engine(domain, name, immediate) ⇒ Object



113
114
115
116
117
118
119
120
# File 'lib/capricorn/server.rb', line 113

def uninstall_engine(domain, name, immediate)
  satellite = Capricorn.system.find_satellite(domain)
  if satellite
    Capricorn.system.uninstall_engine(satellite, name, immediate)
  else
    Capricorn.log "Satellite not found (#{domain})"
  end
end

#uninstall_satellite(domain, immediate) ⇒ Object



77
78
79
80
81
82
83
84
# File 'lib/capricorn/server.rb', line 77

def uninstall_satellite(domain, immediate)
  satellite = Capricorn.system.find_satellite(domain)
  if satellite
    Capricorn.system.uninstall_satellite(satellite, immediate)
  else
    Capricorn.log "Satellite not found (#{domain})"
  end
end

#update_engine(domain, name, options, immediate) ⇒ Object



104
105
106
107
108
109
110
111
# File 'lib/capricorn/server.rb', line 104

def update_engine(domain, name, options, immediate)
  satellite = Capricorn.system.find_satellite(domain)
  if satellite
    Capricorn.system.update_engine(satellite, name, options, immediate)
  else
    Capricorn.log "Satellite not found (#{domain})"
  end
end

#update_gemsObject



51
52
53
# File 'lib/capricorn/server.rb', line 51

def update_gems
  Capricorn.system.gem_update(:all)
end

#update_satellite(domain, immediate) ⇒ Object



68
69
70
71
72
73
74
75
# File 'lib/capricorn/server.rb', line 68

def update_satellite(domain, immediate)
  satellite = Capricorn.system.find_satellite(domain)
  if satellite
    Capricorn.system.update_satellite(satellite, immediate)
  else
    Capricorn.log "Satellite not found (#{domain})"
  end
end

#update_serverObject



45
46
47
48
49
# File 'lib/capricorn/server.rb', line 45

def update_server
  if Capricorn.system.gem_update('capricorn', :user => 'root')
    reload_server
  end
end