Sha256: 2294be52ff57533f55c82abb8d360ce2b519891cc04dae7d3b9efefe86a9ebc5
Contents?: true
Size: 1.71 KB
Versions: 1
Compression:
Stored size: 1.71 KB
Contents
module Rmd NAME = 'autoclient/ringmd' TYPE = ['access', 'error', 'realtime', 'web'] class ServerNotFound < StandardError; end class DeployService def self.deploy(server) validate(server) command = "curl -s #{url(server)}/deploy/#{token(server)}" system_cmd(command) end def self.restart(server) validate(server) command = %{echo "cd #{NAME} && sh restart.sh" | ssh #{master(server)} -p 2200} system_cmd(command) end def self.logs(server) validate(server) command = %{echo "cd #{NAME} && DOCKER_HOST=:2375 docker-compose logs" | ssh #{master(server)} -p 2200} system_cmd(command) end def self.nginx(server, type) validate(server) validate_type(type) command = %{echo "tailf nginx/log/#{type}.log" | ssh #{nginx_url(server)}} system_cmd(command) end def self.bash(server) validate(server) command = %{ssh -t #{master(server)} -p 2200 DOCKER_HOST=:2375 docker exec -it ringmd_new_web_1 bash} system_cmd(command) end private def self.validate(server) fail(ServerNotFound, 'Server not found in the creds file') unless exists?(server) end def self.validate_type(type) fail(TypeNotFound, "Type is not in #{TYPE}") unless TYPE.include?(type) 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 def self.nginx_url(server) Server.get(server).nginx end def self.system_cmd(cmd) $stdout.puts(cmd) system(cmd) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rmdd-0.1.11 | lib/rmd/deploy_service.rb |