Sha256: 2bd30ece5c047587c79213390a33495d6f390f9a9915a0b5da3c3a46e2099ad8

Contents?: true

Size: 811 Bytes

Versions: 2

Compression:

Stored size: 811 Bytes

Contents

module Rmd
  NAME = 'autoclient/ringmd'

  class ServerNotFound < StandardError; end

  class DeployService
    def self.deploy(server)
      validate(server)
      system("curl -s #{url(server)}/deploy/#{token(server)}")
    end

    def self.restart(server)
      validate(server)
      command = %{echo "cd #{NAME} && sh deploy.sh" | ssh #{master(server)}}
      system(command)
    end

    private

    def self.validate(server)
      fail(ServerNotFound, 'Server not found in the creds file') unless exists?(server)
    end

    def self.exists?(server)
      Server.all.include?(server)
    end

    def self.url(server)
      Server.get(server).url
    end

    def self.token(server)
      Server.get(server).token
    end

    def self.master(server)
      Server.get(server).master
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rmdd-0.1.1 lib/rmd/deploy_service.rb
rmdd-0.1.0 lib/rmd/deploy_service.rb