Class: PodsOrz::BinaryServer
- Inherits:
-
Object
- Object
- PodsOrz::BinaryServer
- Defined in:
- lib/podsorz/core/Binary/binary_server.rb
Instance Attribute Summary collapse
-
#http_host ⇒ Object
Returns the value of attribute http_host.
Instance Method Summary collapse
- #__action_upload(pod, file_path, pod_version, extension) ⇒ Object
- #delete_pod_file(pod, pod_version) ⇒ Object
-
#initialize ⇒ BinaryServer
constructor
A new instance of BinaryServer.
- #upload_pod_file(pod, file_path, pod_version) ⇒ Object
Constructor Details
#initialize ⇒ BinaryServer
Returns a new instance of BinaryServer.
10 11 12 |
# File 'lib/podsorz/core/Binary/binary_server.rb', line 10 def initialize() @http_host = "http://192.168.6.127:8899" end |
Instance Attribute Details
#http_host ⇒ Object
Returns the value of attribute http_host.
8 9 10 |
# File 'lib/podsorz/core/Binary/binary_server.rb', line 8 def http_host @http_host end |
Instance Method Details
#__action_upload(pod, file_path, pod_version, extension) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/podsorz/core/Binary/binary_server.rb', line 27 def __action_upload(pod, file_path, pod_version, extension) is_upload_success = false file_name = "#{pod}#{extension}" file_name_path = File.(file_name, file_path) unless File.exist?(file_name_path) Logger.error("#{file_name_path} not exist!") is_upload_success = false return is_upload_success end mutex = Mutex.new() condition_var = ConditionVariable.new wait_thread = Thread.new do mutex.synchronize { condition_var.wait(mutex, 30) } end command = Thread.new do mutex.synchronize { upload_cmd = "curl #{@http_host}/upload -F \"podname=#{pod}\" -F \"version=#{pod_version}\" -F \"file=@#{file_name_path};filename=#{file_name}\"" Logger.warning("upload #{file_name}...\n #{upload_cmd}") Open3.popen3(cmd_list.join(";")) do |stdin , stdout , stderr, wait_thr| while line = stdout.gets puts line if line.include? "\"success\":" is_upload_success = true if line.include? "true" condition_var.signal end end end IO.popen(upload_cmd) do |io| io_lines = io.readlines io_lines.each do |line| puts line end io.close end } end wait_thread.join() Logger.error("upload #{file_name} failure!") unless is_upload_success is_upload_success end |
#delete_pod_file(pod, pod_version) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/podsorz/core/Binary/binary_server.rb', line 82 def delete_pod_file(pod, pod_version) is_delete_success = false mutex = Mutex.new() condition_var = ConditionVariable.new wait_thread = Thread.new do mutex.synchronize { condition_var.wait(mutex, 2) } end command = Thread.new do mutex.synchronize { delete_cmd = "" if pod_version && pod_version.length > 0 delete_cmd = "curl #{@http_host}/delete -d \"podname=#{pod}\";\"version=#{pod_version}\"" else delete_cmd = "curl #{@http_host}/delete -d \"podname=#{pod}\"" end Logger.warning("delete #{pod}...\n #{delete_cmd}") Open3.popen3(delete_cmd) do |stdin , stdout , stderr, wait_thr| while line = stdout.gets puts line if line.include? "\"success\":" is_delete_success = true if line.include? "true" condition_var.signal end end end } end wait_thread.join() Logger.error("delete #{pod} failure!") unless is_delete_success is_delete_success end |
#upload_pod_file(pod, file_path, pod_version) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/podsorz/core/Binary/binary_server.rb', line 14 def upload_pod_file(pod, file_path, pod_version) is_upload_success = false # uplaod zip is_upload_success = __action_upload(pod,file_path,pod_version,".framework.zip") return is_upload_success unless is_upload_success # upload .podspec is_upload_success = __action_upload(pod,file_path,pod_version,".podspec") is_upload_success end |