Giter VIP home page Giter VIP logo

cocaine-framework-ruby's People

Contributors

3hren avatar padm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

toshic fuctor faucct

cocaine-framework-ruby's Issues

Service not working

echo.rb

#!/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()

client.rb

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

Steps:

  • after deploying app here is the output:
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"
}
  • It doesn't return the message to the client or something crash. Here is log for both cases:

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([])

Running a ruby app via cocaine-tool

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.

  1. What should I write in 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>
  1. How can I debug those things? I have found a --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
  1. Here is my simple app code I wrote looking at your python example and 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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.