Class: Desi::LocalInstall

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

Defined Under Namespace

Classes: Release

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of LocalInstall.



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

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

Instance Method Details

#create!Object



75
76
77
# File 'lib/desi/local_install.rb', line 75

def create!
  FileUtils.mkdir_p @workdir
end

#current_dirObject



63
64
65
# File 'lib/desi/local_install.rb', line 63

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

#exists?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/desi/local_install.rb', line 59

def exists?
  @workdir.exist?
end

#launcherObject



99
100
101
# File 'lib/desi/local_install.rb', line 99

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

#logfileObject



95
96
97
# File 'lib/desi/local_install.rb', line 95

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

#pidfileObject



91
92
93
# File 'lib/desi/local_install.rb', line 91

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

#releasesObject



79
80
81
# File 'lib/desi/local_install.rb', line 79

def releases
  Release.all_in(@workdir)
end

#to_pathObject



83
84
85
# File 'lib/desi/local_install.rb', line 83

def to_path
  @workdir.to_s
end

#to_sObject



87
88
89
# File 'lib/desi/local_install.rb', line 87

def to_s
  to_path
end

#update_current_to(release_dir) ⇒ Object



67
68
69
70
71
72
73
# File 'lib/desi/local_install.rb', line 67

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)
end