Class: Dash::Commands::Lock
Constant Summary collapse
- SCOPES =
The deploy lock is scoped to service+destination, so two destinations can deploy at once. Server-scoped resources — above all the single dash-proxy container a host runs for every destination on it — need a lock that every destination contends for, hence :server.
%i[ destination server ].freeze
Constants inherited from Base
Base::DOCKER_HEALTH_STATUS_FORMAT, Base::NO_HEALTHCHECK
Instance Attribute Summary collapse
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Attributes inherited from Base
Instance Method Summary collapse
- #acquire(message, version) ⇒ Object
- #ensure_locks_directory ⇒ Object
-
#initialize(config, scope: :destination) ⇒ Lock
constructor
A new instance of Lock.
- #release ⇒ Object
- #status ⇒ Object
Methods inherited from Base
#container_id_for, #ensure_docker_installed, #ensure_run_directory, #make_directory, #make_directory_for, #read_file, #remove_directory, #remove_file, #run_over_ssh
Constructor Details
#initialize(config, scope: :destination) ⇒ Lock
Returns a new instance of Lock.
14 15 16 17 18 19 |
# File 'lib/dash/commands/lock.rb', line 14 def initialize(config, scope: :destination) raise ArgumentError, "Unknown lock scope: #{scope}" unless SCOPES.include?(scope) super(config) @scope = scope end |
Instance Attribute Details
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
12 13 14 |
# File 'lib/dash/commands/lock.rb', line 12 def scope @scope end |
Instance Method Details
#acquire(message, version) ⇒ Object
21 22 23 24 25 |
# File 'lib/dash/commands/lock.rb', line 21 def acquire(, version) combine \ [ :mkdir, lock_dir ], write_lock_details(, version) end |
#ensure_locks_directory ⇒ Object
39 40 41 |
# File 'lib/dash/commands/lock.rb', line 39 def ensure_locks_directory [ :mkdir, "-p", locks_dir ] end |
#release ⇒ Object
27 28 29 30 31 |
# File 'lib/dash/commands/lock.rb', line 27 def release combine \ [ :rm, lock_details_file ], [ :rm, "-r", lock_dir ] end |
#status ⇒ Object
33 34 35 36 37 |
# File 'lib/dash/commands/lock.rb', line 33 def status combine \ stat_lock_dir, read_lock_details end |