Class: Hudson::Installation

Inherits:
Object show all
Defined in:
lib/hudson/installation.rb

Defined Under Namespace

Classes: Progress

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(shell, opts = {}) ⇒ Installation

Returns a new instance of Installation.



5
6
7
8
9
10
11
12
# File 'lib/hudson/installation.rb', line 5

def initialize(shell, opts = {})
  @shell = shell
  @options = opts
  @serverhome = File.expand_path(@options[:home])
  @warfile = File.join(File.dirname(@serverhome), "hudson.war")
  @versionfile = "#{@serverhome}/version.txt"
  @control_port = opts[:control]
end

Instance Attribute Details

#directoryObject (readonly)

Returns the value of attribute directory.



3
4
5
# File 'lib/hudson/installation.rb', line 3

def directory
  @directory
end

Instance Method Details

#hudson_stockObject



44
45
46
# File 'lib/hudson/installation.rb', line 44

def hudson_stock
  ENV['HUDSON_STOCK']
end

#kill!Object



31
32
33
34
35
36
37
# File 'lib/hudson/installation.rb', line 31

def kill!
  require 'socket'
  TCPSocket.open("localhost", @control_port) do |sock|
    sock.write("0")
  end
  exit
end

#launch!Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/hudson/installation.rb', line 14

def launch!
  unless warfile?
    @shell.say "no server currently installed."
    upgrade!
  end
  javatmp = File.join(@serverhome, "javatmp")
  FileUtils.mkdir_p javatmp
  ENV['HUDSON_HOME'] = @serverhome
  cmd = ["java", "-Djava.io.tmpdir=#{javatmp}", "-jar", @warfile]
  cmd << "--daemon" if @options[:daemon]
  cmd << "--logfile=#{File.expand_path(@options[:logfile])}" if @options[:logfile]
  cmd << "--httpPort=#{@options[:port]}"
  cmd << "--controlPort=#{@control_port}"
  @shell.say cmd.join(" ")
  exec(*cmd)
end

#upgrade!Object



39
40
41
42
# File 'lib/hudson/installation.rb', line 39

def upgrade!
  FileUtils.mkdir_p @serverhome
  hudson_stock ? upgrade_from_fixture_stock : upgrade_from_network_stock
end