Sha256: 95a5b5909a785451ee2e51cae382aacffeee2c48854b90a3ad983fce340899c8
Contents?: true
Size: 1.14 KB
Versions: 2
Compression:
Stored size: 1.14 KB
Contents
#!/usr/bin/env ruby require 'drb' require 'optparse' require 'mega/synchash' require 'nitro/session' # A distributes session store implemented as # a simple DRb server. address = '127.0.0.1' port = 9069 debug = false parser = OptionParser.new do |opts| opts.banner = 'Usage: drbserver.rb [options]' opts.separator '' opts.separator 'Specific options:' opts.on('-a A', '--address A', 'Listening address.') do |a| address = a end opts.on('-p P', '--port P', Integer, 'Listening port.') do |p| port = p end opts.on('-D', '--debug', 'Run in debug mode.') do |p| debug = true end opts.on_tail('-h', '--help', 'Show this message.') do puts opts exit end end begin parser.parse!(ARGV) rescue OptionParser::InvalidOption puts 'Invalid option, pass the --help parameter to get help!' exit end sessions = SyncHash.new if debug class << sessions def []=(k, v) puts "WRITE: #{k} = #{v}" super end def [](k) puts "READ: #{k}" super end end end DRb.start_service("druby://#{address}:#{port}", sessions) DRb.thread.join # * George Moschovitis <gm@navel.gr>
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
nitro-0.23.0 | lib/nitro/session/drbserver.rb |
nitro-0.24.0 | lib/nitro/session/drbserver.rb |