Class: Nvoi::Cli::Unlock::Command
- Inherits:
-
Object
- Object
- Nvoi::Cli::Unlock::Command
- Defined in:
- lib/nvoi/cli/unlock/command.rb
Overview
Command removes deployment lock from remote server
Instance Method Summary collapse
-
#initialize(options) ⇒ Command
constructor
A new instance of Command.
- #run ⇒ Object
Constructor Details
#initialize(options) ⇒ Command
Returns a new instance of Command.
8 9 10 11 |
# File 'lib/nvoi/cli/unlock/command.rb', line 8 def initialize() = @log = Nvoi.logger end |
Instance Method Details
#run ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/nvoi/cli/unlock/command.rb', line 13 def run config_path = resolve_config_path @config = Utils::ConfigLoader.load(config_path) # Apply branch override if specified apply_branch_override if [:branch] # Initialize cloud provider @provider = External::Cloud.for(@config) # Find main server server = @provider.find_server(@config.server_name) raise Errors::ServiceError, "server not found: #{@config.server_name}" unless server ssh = External::Ssh.new(server.public_ipv4, @config.ssh_key_path) lock_file = @config.namer.deployment_lock_file_path # Check if lock exists and show info output = ssh.execute("test -f #{lock_file} && cat #{lock_file} || echo ''").strip if output.empty? @log.info "No lock file found: %s", lock_file return end = output.to_i if > 0 lock_time = Time.at() age = Time.now - lock_time @log.info "Lock file age: %ds (since %s)", age.round, lock_time.strftime("%H:%M:%S") end ssh.execute("rm -f #{lock_file}") @log.success "Removed lock file: %s", lock_file end |