Created
June 10, 2013 17:43
-
-
Save ardavis/5750754 to your computer and use it in GitHub Desktop.
Attempting to use Celluloid::Websocket::Client within a Sidekiq::Worker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyActor | |
include Celluloid | |
include Celluloid::Logger | |
attr_reader :client | |
def initialize | |
@client ||= Celluloid::WebSocket::Client.new('wss://localhost:10000', current_actor) | |
end | |
end | |
class RunCommandWorker | |
include Sidekiq::Worker | |
sidekiq_options retry: false, backtrace: true | |
def perform(command) | |
websocket_client = MyActor.new.client | |
Net::SSH.start(...) do |ssh| | |
ssh.exec!(command) do |channel, stream, data| | |
websocket_client.text CGI::escape(data.chop) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment