- cd ../regression-tests.nobackend/
- ./runtests
- test ! -s ./failed_tests
+ - cat /tmp/remotebackend.txt.* | sort
notifications:
irc:
channels:
def initialize(server, dnsbackend)
@dnsbackend = dnsbackend
@semaphore = Mutex.new
- @f = File.open("/tmp/tmp.txt","a")
+ @f = File.open("/tmp/remotebackend.txt","a")
@f.sync
end
h = Handler.new("#{File.dirname(__FILE__)}/remote.sqlite3")
-f = File.open "/tmp/tmp.txt","a"
+f = File.open "/tmp/remotebackend.txt.#{$$}","a"
f.sync = true
STDOUT.sync = true
begin
STDIN.each_line do |line|
- f.puts line
# expect json
input = {}
line = line.strip
+ f.puts "#{Time.now.to_f}: [pipe] #{line}"
next if line.empty?
begin
input = JSON.parse(line)
res, log = h.send(method)
end
puts ({:result => res, :log => log}).to_json
- f.puts({:result => res, :log => log}).to_json
+ f.puts "#{Time.now.to_f} [pipe]: #{({:result => res, :log => log}).to_json}"
rescue JSON::ParserError
puts ({:result => false, :log => "Cannot parse input #{line}"}).to_json
+ f.puts "#{Time.now.to_f} [pipe]: #{({:result => false, :log => "Cannot parse input #{line}"}).to_json}"
next
end
end
+++ /dev/null
-pipe-backend.rb
\ No newline at end of file
--- /dev/null
+#!/usr/bin/env ruby
+require "rubygems"
+require 'bundler/setup'
+require 'json'
+$:.unshift File.dirname(__FILE__)
+require "backend"
+
+h = Handler.new("#{File.dirname(__FILE__)}/remote.sqlite3")
+
+f = File.open "/tmp/remotebackend.txt","a"
+f.sync = true
+
+STDOUT.sync = true
+begin
+ STDIN.each_line do |line|
+ # expect json
+ input = {}
+ line = line.strip
+ f.puts "#{Time.now.to_f}: [unix] #{line}"
+ next if line.empty?
+ begin
+ input = JSON.parse(line)
+ next unless input and input["method"]
+ method = "do_#{input["method"].downcase}"
+ args = input["parameters"]
+
+ if h.respond_to?(method.to_sym) == false
+ res = false
+ elsif args.size > 0
+ res, log = h.send(method,args)
+ else
+ res, log = h.send(method)
+ end
+ puts ({:result => res, :log => log}).to_json
+ f.puts "#{Time.now.to_f} [unix]: #{({:result => res, :log => log}).to_json}"
+ rescue JSON::ParserError
+ f.puts "#{Time.now.to_f} [unix]: #{({:result => false, :log => "Cannot parse input #{line}"}).to_json}"
+ next
+ end
+ end
+rescue SystemExit, Interrupt
+end
-#!/usr/bin/ruby1.9.1
-
#!/usr/bin/env ruby
require "rubygems"
require 'bundler/setup'
h = Handler.new("#{File.dirname(__FILE__)}/remote.sqlite3")
-f = File.open "/tmp/tmp.txt","a"
+f = File.open "/tmp/remotebackend.txt.#{$$}","a"
f.sync = true
begin
while(true) do
line = ""
rc = socket.recv_string line
- f.puts line
# expect json
input = {}
line = line.strip
+ f.puts "#{Time.now.to_f}: [zmq] #{line}"
next if line.empty?
begin
input = JSON.parse(line)
res, log = h.send(method)
end
socket.send_string ({:result => res, :log => log}).to_json, 0
- f.puts({:result => res, :log => log}).to_json
+ f.puts "#{Time.now.to_f} [zmq]: #{({:result => res, :log => log}).to_json}"
rescue JSON::ParserError
socket.send_string ({:result => false, :log => "Cannot parse input #{line}"}).to_json
+ f.puts "#{Time.now.to_f} [zmq]: #{({:result => false, :log => "Cannot parse input #{line}"}).to_json}"
next
end
end
def initialize(server, dnsbackend)
@dnsbackend = dnsbackend
@semaphore = Mutex.new
- @f = File.open("/tmp/tmp.txt","a")
+ @f = File.open("/tmp/remotebackend.txt.#{$$}","a")
end
def parse_arrays(params)
args = parse_arrays args
- @f.puts method
- @f.puts args
+ @f.puts "#{Time.now.to_f} [http]: #{({:method=>method,:parameters=>args}).to_json}"
@semaphore.synchronize do
if @dnsbackend.respond_to?(method.to_sym)
res["Content-Type"] = "application/javascript; charset=utf-8"
res.body = ({:result => false, :log => ["Method not found"]}).to_json
end
+
+ @f.puts "#{Time.now.to_f} [http]: #{res.body}"
end
end
def initialize(server, dnsbackend)
@dnsbackend = dnsbackend
@semaphore = Mutex.new
- @f = File.open("/tmp/tmp.txt","a")
+ @f = File.open("/tmp/remotebackend.txt.#{$$}","a")
+ @f.sync
end
def do_POST(req,res)
method = tmp["method"].downcase
method = "do_#{method}"
args = tmp["parameters"]
-
- @f.puts method
- @f.puts args
+
+ @f.puts "#{Time.now.to_f} [http/json]: #{({:method=>method,:parameters=>args}).to_json}"
@semaphore.synchronize do
if @dnsbackend.respond_to?(method.to_sym)
res["Content-Type"] = "application/javascript; charset=utf-8"
res.body = ({:result => false, :log => ["Method not found"]}).to_json
end
+ @f.puts "#{Time.now.to_f} [http/json]: #{res.body}"
end
end
end
require './unittest'
h = Handler.new()
-f = File.open "/tmp/tmp.txt","a"
+f = File.open "/tmp/remotebackend.txt.#{$$}","a"
+f.sync
STDOUT.sync = true
begin
STDIN.each_line do |line|
- f.puts line
+ f.puts "#{Time.now.to_f}: [pipe] #{line}"
# expect json
input = {}
line = line.strip
res, log = h.send(method)
end
puts ({:result => res, :log => log}).to_json
- f.puts({:result => res, :log => log}).to_json
+ f.puts "#{Time.now.to_f} [pipe]: #{({:result => res, :log => log}).to_json}"
rescue JSON::ParserError
puts ({:result => false, :log => "Cannot parse input #{line}"}).to_json
+ f.puts "#{Time.now.to_f} [pipe]: #{({:result => false, :log => "Cannot parse input #{line}"}).to_json}"
next
end
end
def initialize(server, dnsbackend)
@dnsbackend = dnsbackend
@semaphore = Mutex.new
- @f = File.open("/tmp/tmp.txt","a")
+ @f = File.open("/tmp/remotebackend.txt.#{$$}","a")
+ @f.sync
end
def do_POST(req,res)
method = url.shift.downcase
method = "do_#{method}"
args = JSON::parse(req.query["parameters"])
-
- @f.puts method
- @f.puts args
+
+ @f.puts "#{Time.now.to_f} [http/post]: #{({:method=>method,:parameters=>args}).to_json}"
@semaphore.synchronize do
if @dnsbackend.respond_to?(method.to_sym)
res["Content-Type"] = "application/javascript; charset=utf-8"
res.body = ({:result => false, :log => ["Method not found"]}).to_json
end
+ @f.puts "#{Time.now.to_f} [http/post]: #{res.body}"
end
end
end
require './unittest'
h = Handler.new()
-f = File.open "/tmp/tmp.txt","a"
+f = File.open "/tmp/remotebackend.txt.#{$$}","a"
+f.sync = true
+
runcond=true
trap('INT') { runcond = false }
while(runcond) do
line = ""
rc = socket.recv_string line
- f.puts line
# expect json
input = {}
line = line.strip
+
+ f.puts "#{Time.now.to_f}: [zmq] #{line}"
next if line.empty?
begin
input = JSON.parse(line)
res, log = h.send(method)
end
socket.send_string ({:result => res, :log => log}).to_json, 0
- f.puts({:result => res, :log => log}).to_json
+ f.puts "#{Time.now.to_f} [z,q]: #{({:result => res, :log => log}).to_json}"
rescue JSON::ParserError
socket.send_string ({:result => false, :log => "Cannot parse input #{line}"}).to_json
+ f.puts "#{Time.now.to_f} [zmq]: #{({:result => false, :log => "Cannot parse input #{line}"}).to_json}"
next
end
end