Class: Dolphin::Lock

Inherits:
Base
  • Object
show all
Defined in:
lib/dolphin/lock.rb

Overview

Use lock to avoid simultaneous deployments

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Dolphin::Base

Instance Method Details

#checkObject



5
6
7
8
9
10
11
12
13
14
# File 'lib/dolphin/lock.rb', line 5

def check
  command = "if [ -e #{@lock_file} ]; then cat #{@lock_file}; fi"
  output = capture(command, @lead_server)
  if output.empty?
    puts "OK to proceed"
  else
    puts "[output]: #{output}"
    abort "\e[0;31m A deployment is already in progress\n Please wait for its completion\nOr in case of stale lock, remove #{@lock_file} to unlock \e[0m\n"
  end
end

#createObject



17
18
19
20
# File 'lib/dolphin/lock.rb', line 17

def create
  command = "echo '#{@lock_message}' > #{@lock_file}"
  puts capture(command, @lead_server)
end

#releaseObject



23
24
25
26
# File 'lib/dolphin/lock.rb', line 23

def release
  command = "rm -f #{@lock_file}"
  puts capture(command, @lead_server)
end