Class: Desi::LocalInstall

Inherits:
Object
  • Object
show all
Defined in:
lib/desi/local_install.rb,
lib/desi/local_install/release.rb

Defined Under Namespace

Classes: Release

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(workdir = nil, opts = {}) ⇒ LocalInstall

Returns a new instance of LocalInstall.



13
14
15
16
17
# File 'lib/desi/local_install.rb', line 13

def initialize(workdir = nil, opts = {})
  @verbose = opts[:verbose]
  @workdir = Pathname(File.expand_path(workdir || Desi.configuration.directory))
  create!
end

Class Method Details

.current_release_is_pre_one_zero?Boolean

Returns:

  • (Boolean)


8
9
10
11
# File 'lib/desi/local_install.rb', line 8

def self.current_release_is_pre_one_zero?
  current = new.current_release
  current && current.pre_one_zero?
end

Instance Method Details



36
37
38
39
40
41
42
43
# File 'lib/desi/local_install.rb', line 36

def add_data_symlink(release_dir)
  current_dir_must_be_nil_or_symlink!
  symlink = current_dir.join('data')
  FileUtils.mkdir_p data_dir
  puts " * Updating data dir symlink (#{symlink} -> #{data_dir})" if @verbose
  FileUtils.ln_sf(data_dir, symlink)
  self
end

#create!Object



45
46
47
# File 'lib/desi/local_install.rb', line 45

def create!
  FileUtils.mkdir_p @workdir
end

#current_dirObject



23
24
25
# File 'lib/desi/local_install.rb', line 23

def current_dir
  @current_dir ||= @workdir.join('current')
end

#current_releaseObject



53
54
55
# File 'lib/desi/local_install.rb', line 53

def current_release
  releases.find {|r| r.current? }
end

#data_dirObject



61
62
63
# File 'lib/desi/local_install.rb', line 61

def data_dir
  @data_dir ||= @workdir.join('data')
end

#exists?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/desi/local_install.rb', line 19

def exists?
  @workdir.exist?
end

#launcherObject



77
78
79
# File 'lib/desi/local_install.rb', line 77

def launcher
  current_dir.join('bin', 'elasticsearch')
end

#logfileObject



73
74
75
# File 'lib/desi/local_install.rb', line 73

def logfile
  current_dir.join('logs', 'elasticsearch.log')
end

#pidfileObject



69
70
71
# File 'lib/desi/local_install.rb', line 69

def pidfile
  @workdir.join('elasticsearch.pid')
end

#releasesObject



49
50
51
# File 'lib/desi/local_install.rb', line 49

def releases
  Release.all_in(@workdir)
end

#to_pathObject



57
58
59
# File 'lib/desi/local_install.rb', line 57

def to_path
  @workdir.to_s
end

#to_sObject



65
66
67
# File 'lib/desi/local_install.rb', line 65

def to_s
  to_path
end

#update_current_to(release_dir) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/desi/local_install.rb', line 27

def update_current_to(release_dir)
  current_dir_must_be_nil_or_symlink!

  puts " * Updating #{current_dir} symlink" if @verbose
  FileUtils.remove(current_dir) if current_dir.exist?
  FileUtils.ln_sf(release_dir, current_dir)
  self
end