Class: Desi::LocalInstall
- Inherits:
-
Object
- Object
- Desi::LocalInstall
- 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
- #add_data_symlink(release_dir) ⇒ Object
- #create! ⇒ Object
- #current_dir ⇒ Object
- #current_release ⇒ Object
- #data_dir ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(workdir = nil, opts = {}) ⇒ LocalInstall
constructor
A new instance of LocalInstall.
- #launcher ⇒ Object
- #logfile ⇒ Object
- #pidfile ⇒ Object
- #releases ⇒ Object
- #to_path ⇒ Object
- #to_s ⇒ Object
- #update_current_to(release_dir) ⇒ Object
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.(workdir || Desi.configuration.directory)) create! end |
Class Method Details
.current_release_is_pre_one_zero? ⇒ 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
#add_data_symlink(release_dir) ⇒ Object
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_dir ⇒ Object
23 24 25 |
# File 'lib/desi/local_install.rb', line 23 def current_dir @current_dir ||= @workdir.join('current') end |
#current_release ⇒ Object
53 54 55 |
# File 'lib/desi/local_install.rb', line 53 def current_release releases.find {|r| r.current? } end |
#data_dir ⇒ Object
61 62 63 |
# File 'lib/desi/local_install.rb', line 61 def data_dir @data_dir ||= @workdir.join('data') end |
#exists? ⇒ Boolean
19 20 21 |
# File 'lib/desi/local_install.rb', line 19 def exists? @workdir.exist? end |
#launcher ⇒ Object
77 78 79 |
# File 'lib/desi/local_install.rb', line 77 def launcher current_dir.join('bin', 'elasticsearch') end |
#logfile ⇒ Object
73 74 75 |
# File 'lib/desi/local_install.rb', line 73 def logfile current_dir.join('logs', 'elasticsearch.log') end |
#pidfile ⇒ Object
69 70 71 |
# File 'lib/desi/local_install.rb', line 69 def pidfile @workdir.join('elasticsearch.pid') end |
#releases ⇒ Object
49 50 51 |
# File 'lib/desi/local_install.rb', line 49 def releases Release.all_in(@workdir) end |
#to_path ⇒ Object
57 58 59 |
# File 'lib/desi/local_install.rb', line 57 def to_path @workdir.to_s end |
#to_s ⇒ Object
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 |