Skip to content

Instantly share code, notes, and snippets.

@ardavis
Created June 10, 2013 17:43
Show Gist options
  • Save ardavis/5750754 to your computer and use it in GitHub Desktop.
Save ardavis/5750754 to your computer and use it in GitHub Desktop.
Attempting to use Celluloid::Websocket::Client within a Sidekiq::Worker
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