cocaine / cocaine-framework-ruby Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU Lesser General Public License v3.0
License: GNU Lesser General Public License v3.0
Hello, I am trying to run a simple ruby app like the qr-code generator from the tutorial (https://github.com/cocaine/cocaine-vagrant) and I can't understand some things.
manifest.json
so the app could be started? I have used this configuration and cocaine-tool app start
tells me everything is fine:# manifest.json
{
"slave": "main.rb"
}
It seems like it does not work at all, because in case of python app I see this when do an http request and call ps:
cocaine 11614 2166 3 12:40 ? 00:00:00 python /var/spool/cocaine/qr/app.py --app qr --endpoint /var/run/cocaine/qr.2166 --locator precise64:10053 --uuid da02ac97-7637-4c9
And this is the case of ruby app and the request hangs until I cocaine-tool app stop
the ruby app:
cocaine 11613 2166 0 12:40 ? 00:00:00 [service/node] <defunct>
--debug all
option for cocaine-tool
commands but it does not seem useful at all. Also, I was trying to read the /var/log/cocaine-python-proxy.log file and its content was not any more helpful:[2016-04-17 12:18:00,526] INFO : Start asynchronous reconnect ruby
[2016-04-17 12:18:00,528] INFO : Reconnect ruby 37678096 to 127.0.1.1:45734 successfully.
[2016-04-17 12:18:00,528] INFO : Next update 37678096 after 199 second
[2016-04-17 12:18:01,304] INFO : Start asynchronous reconnect ruby
[2016-04-17 12:18:01,306] INFO : Reconnect ruby 37676560 to 127.0.1.1:45734 successfully.
[2016-04-17 12:18:01,306] INFO : Next update 37676560 after 193 second
[2016-04-17 12:18:03,523] INFO : Move to inactive queue ruby 127.0.1.1:45734 from pool with active 7
[2016-04-17 12:18:05,528] INFO : Start asynchronous reconnect ruby
[2016-04-17 12:18:05,530] INFO : Reconnect ruby 38567504 to 127.0.1.1:45734 successfully.
[2016-04-17 12:18:05,530] INFO : Next update 38567504 after 147 second
cocaine-framework-ruby
gem:# main.rb
require 'cocaine'
worker = Cocaine::WorkerFactory.create
worker.on 'generate' do |tx_channel, rx|
# ...
end
worker.run
Still I have no idea what can I do inside a block to respond with something: in cocaine-framework-ruby
gem it is said that Cocaine::TxChannel
is a Writer channel and should be used for patching the response, but the problem is that it does not have any public methods on it.
#!/usr/bin/env ruby
require 'cocaine'
require 'cocaine/server/http'
$log = Logger.new(STDERR)
$log.level = Logger::DEBUG
class EchoStreaming
def execute(request, response)
df = request.read
df.callback do |msg|
$log.debug "Message received: #{msg}. Sending it back more happily."
response.write msg
response.write msg + '!'
response.write msg + '! :)'
response.close
end
end
end
w = Cocaine::WorkerFactory.create
w.on 'Echo', EchoStreaming.new
w.run()
require_relative "#{File.dirname(__FILE__)}/../lib/cocaine/client/service"
require_relative "#{File.dirname(__FILE__)}/../lib/cocaine/protocol"
require_relative "#{File.dirname(__FILE__)}/../lib/cocaine/synchrony/service"
require_relative "#{File.dirname(__FILE__)}/../spec/stub_server"
EM.synchrony do
service = Cocaine::Synchrony::Service.new 'Echo'
ch = service.enqueue('Echo', 'sent this message')
msg = ch.collect(3)
puts "Final Message: #{msg}"
EM.stop
end
Setting timeout to the 120.000000s
[ OK ] Loading manifest
[ OK ] Reading package "echo.tar.gz"
[ OK ] Uploading manifest
[ OK ] Uploading application "Echo"
[ OK ] Loading profile
[ OK ] Uploading "EchoProfile"
{
"Echo": "the app has been started"
}
crash.log:
ruby client.rb
D, [2013-11-18T16:23:53.115697 #11971] DEBUG -- : connection established with service 'locator' at ["localhost", 20053]
D, [2013-11-18T16:23:53.115791 #11971] DEBUG -- : resolving service 'node'
D, [2013-11-18T16:23:53.115840 #11971] DEBUG -- : invoking 'locator' method 0 with ["node"]
D, [2013-11-18T16:23:53.115875 #11971] DEBUG -- : invoking 0 with ["node"]
D, [2013-11-18T16:23:53.116091 #11971] DEBUG -- : received: [1] Chunk(["\x93\x90\u0001\x80"])
D, [2013-11-18T16:23:53.116322 #11971] DEBUG -- : connection established with service 'locator' at ["localhost", 10053]
D, [2013-11-18T16:23:53.116365 #11971] DEBUG -- : resolving service 'Echo'
D, [2013-11-18T16:23:53.116403 #11971] DEBUG -- : invoking 'locator' method 0 with ["Echo"]
D, [2013-11-18T16:23:53.116430 #11971] DEBUG -- : invoking 0 with ["Echo"]
D, [2013-11-18T16:23:53.116717 #11971] DEBUG -- : received: [1] Chunk(["\x93\x92\xB8shakeel-ProBook-4540s\xCD\xC1\e\u0001\x82\u0000\xA7enqueue\u0001\xA4info"])
D, [2013-11-18T16:23:53.116798 #11971] DEBUG -- : service 'Echo' resolved: [["shakeel-ProBook-4540s", 49435], 1, {0=>"enqueue", 1=>"info"}]
D, [2013-11-18T16:23:53.116960 #11971] DEBUG -- : connection established with service 'Echo' at ["shakeel-ProBook-4540s", 49435]
D, [2013-11-18T16:23:53.117041 #11971] DEBUG -- : invoking 'Echo' method 0 with ["Echo", "sent this message"]
D, [2013-11-18T16:23:53.117076 #11971] DEBUG -- : invoking 0 with ["Echo", "sent this message"]
D, [2013-11-18T16:23:53.117139 #11971] DEBUG -- : received: [1] Choke([])
D, [2013-11-18T16:23:53.220947 #11971] DEBUG -- : received: [1] Error([-100, "there is no handler for event Echo"])
/home/shakeel/projects/rpc/ruby/cocaine-framework-ruby/lib/cocaine/future.rb:11:in `get': [-100] there is no handler for event Echo (Cocaine::ServiceError)
from /home/shakeel/projects/rpc/ruby/cocaine-framework-ruby/lib/cocaine/synchrony/channel.rb:24:in `block in each'
from /home/shakeel/projects/rpc/ruby/cocaine-framework-ruby/lib/cocaine/synchrony/channel.rb:22:in `loop'
from /home/shakeel/projects/rpc/ruby/cocaine-framework-ruby/lib/cocaine/synchrony/channel.rb:22:in `each'
from /home/shakeel/projects/rpc/ruby/cocaine-framework-ruby/lib/cocaine/synchrony/channel.rb:54:in `collect_until_count'
from /home/shakeel/projects/rpc/ruby/cocaine-framework-ruby/lib/cocaine/synchrony/channel.rb:35:in `collect'
from client.rb:25:in `block in <main>'
from /usr/local/lib/ruby/gems/1.9.1/gems/em-synchrony-1.0.3/lib/em-synchrony.rb:38:in `block (2 levels) in synchrony'
noresponse.log:
ruby client.rb
D, [2013-11-18T16:03:09.400906 #11082] DEBUG -- : connection established with service 'locator' at ["localhost", 10053]
D, [2013-11-18T16:03:09.401036 #11082] DEBUG -- : resolving service 'Echo'
D, [2013-11-18T16:03:09.401081 #11082] DEBUG -- : invoking 'locator' method 0 with ["Echo"]
D, [2013-11-18T16:03:09.401118 #11082] DEBUG -- : invoking 0 with ["Echo"]
D, [2013-11-18T16:03:09.401435 #11082] DEBUG -- : received: [1] Chunk(["\x93\x92\xB8shakeel-HP-ProBook-4540s\xCD\xD8\u0001\u0001\x82\u0000\xA7enqueue\u0001\xA4info"])
D, [2013-11-18T16:03:09.401523 #11082] DEBUG -- : service 'Echo' resolved: [["shakeel-ProBook-4540s", 55297], 1, {0=>"enqueue", 1=>"info"}]
D, [2013-11-18T16:03:09.401694 #11082] DEBUG -- : connection established with service 'Echo' at ["shakeel-ProBook-4540s", 55297]
D, [2013-11-18T16:03:09.401778 #11082] DEBUG -- : invoking 'Echo' method 0 with ["Echo", "Shakeel sent this message"]
D, [2013-11-18T16:03:09.401812 #11082] DEBUG -- : invoking 0 with ["Echo", "Shakeel sent this message"]
D, [2013-11-18T16:03:09.401877 #11082] DEBUG -- : received: [1] Choke([])
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.