Support all platform operations over zmq
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
require "bundler/setup"
|
||||
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
||||
|
||||
require "pipeline"
|
||||
Pipeline.load_config(File.expand_path('../../config/pipeline.yml', __FILE__))
|
||||
Pipeline.build_analyzer(ARGV[0])
|
||||
|
||||
# Pipeline.build_analyzer("ruby")
|
||||
# Pipeline.release("ruby")
|
||||
# Pipeline.analyzer("ruby")
|
||||
41
bin/builderd
Executable file → Normal file
41
bin/builderd
Executable file → Normal file
@@ -2,42 +2,7 @@
|
||||
require "bundler/setup"
|
||||
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
||||
|
||||
require 'ffi-rzmq'
|
||||
require "pipeline"
|
||||
|
||||
class PipelineRpcServer
|
||||
|
||||
attr_reader :context, :socket
|
||||
|
||||
def initialize
|
||||
@context = ZMQ::Context.new(1)
|
||||
@socket = context.socket(ZMQ::REP)
|
||||
socket.bind("tcp://*:5555")
|
||||
end
|
||||
|
||||
def run
|
||||
require "pipeline"
|
||||
Pipeline.load_config(File.expand_path('../../config/pipeline.yml', __FILE__))
|
||||
|
||||
loop do
|
||||
request = ''
|
||||
socket.recv_string(request)
|
||||
puts "Received request. Data: #{request.inspect}"
|
||||
if request.start_with? "build-analyzer_"
|
||||
_, arg = request.split("_")
|
||||
result = Pipeline.build_analyzer(arg)
|
||||
socket.send_string(result.to_json)
|
||||
elsif request.start_with? "release-analyzer_"
|
||||
_, arg = request.split("_")
|
||||
result = Pipeline.release(arg)
|
||||
socket.send_string(result.to_json)
|
||||
else
|
||||
socket.send_string("done")
|
||||
end
|
||||
end
|
||||
puts msg
|
||||
socket.send_string(msg)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
PipelineRpcServer.new.run
|
||||
Pipeline.load_config(File.expand_path('../../config/pipeline.yml', __FILE__))
|
||||
Pipeline.daemon
|
||||
|
||||
37
bin/client.rb
Normal file
37
bin/client.rb
Normal file
@@ -0,0 +1,37 @@
|
||||
require 'ffi-rzmq'
|
||||
require 'json'
|
||||
require 'yaml'
|
||||
require 'securerandom'
|
||||
|
||||
class PipelineClient
|
||||
|
||||
attr_reader :context, :socket
|
||||
|
||||
def initialize
|
||||
@context = ZMQ::Context.new(1)
|
||||
@socket = context.socket(ZMQ::REQ)
|
||||
socket.setsockopt(ZMQ::LINGER, 0)
|
||||
socket.connect("tcp://localhost:5555")
|
||||
end
|
||||
|
||||
def send_msg(msg)
|
||||
socket.send_string(msg)
|
||||
response = ''
|
||||
rc = socket.recv_string(response)
|
||||
parsed = JSON.parse(response)
|
||||
parsed
|
||||
end
|
||||
|
||||
def build_analyzer(track_slug)
|
||||
send_msg("build-analyzer_#{track_slug}")
|
||||
end
|
||||
|
||||
def release_latest(track_slug)
|
||||
send_msg("release-analyzer_#{track_slug}")
|
||||
end
|
||||
|
||||
def analyze(track_slug, exercise_slug, solution_slug, iteration_folder)
|
||||
send_msg("analyze_#{track_slug}|#{exercise_slug}|#{solution_slug}|#{iteration_folder}")
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,44 +1,13 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require 'ffi-rzmq'
|
||||
require 'json'
|
||||
|
||||
class PipelineClient
|
||||
|
||||
attr_reader :context, :socket
|
||||
|
||||
def initialize
|
||||
@context = ZMQ::Context.new(1)
|
||||
@socket = context.socket(ZMQ::REQ)
|
||||
socket.setsockopt(ZMQ::LINGER, 0)
|
||||
socket.connect("tcp://localhost:5555")
|
||||
end
|
||||
|
||||
def send_msg(msg)
|
||||
socket.send_string(msg)
|
||||
response = ''
|
||||
rc = socket.recv_string(response)
|
||||
parsed = JSON.parse(response)
|
||||
parsed
|
||||
end
|
||||
|
||||
def build_analyzer(track_slug)
|
||||
send_msg("build-analyzer_#{track_slug}")
|
||||
end
|
||||
|
||||
def release_latest(track_slug)
|
||||
send_msg("release-analyzer_#{track_slug}")
|
||||
end
|
||||
|
||||
end
|
||||
require_relative "./client"
|
||||
|
||||
pipeline = PipelineClient.new
|
||||
r = pipeline.analyze("ruby", "two-fer", "soln-42", "s3://exercism-dev/iterations/fff07700-e1c3-402d-8937-823aeefb159f")
|
||||
r["logs"].each do |log_line|
|
||||
puts "+ #{log_line["cmd"]}"
|
||||
puts log_line["stdout"]
|
||||
puts log_line["stderr"]
|
||||
end
|
||||
|
||||
# result = pipeline.build_analyzer("ruby")
|
||||
# result["logs"].each do |log_line|
|
||||
# puts "+ #{log_line["cmd"]}"
|
||||
# puts log_line["stdout"]
|
||||
# puts log_line["stderr"]
|
||||
# end
|
||||
|
||||
pipeline.release_latest("ruby")
|
||||
puts r["result"]
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
#!/usr/bin/env ruby
|
||||
require "bundler/setup"
|
||||
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
||||
|
||||
require "pipeline"
|
||||
Pipeline.load_config(File.expand_path('../../config/pipeline.yml', __FILE__))
|
||||
|
||||
Pipeline.release(ARGV[0])
|
||||
Reference in New Issue
Block a user