Sha256: 7844ac6e0324270254f01ea8b59757a480ae88f148d0672c2f1abd85a55e62ea

Contents?: true

Size: 1.18 KB

Versions: 6

Compression:

Stored size: 1.18 KB

Contents

#!/usr/bin/env ruby

# * George Moschovitis  <gm@navel.gr>
# (c) 2004-2005 Navel, all rights reserved.
# $Id: drbserver.rb 1 2005-04-11 11:04:30Z gmosx $

require 'drb'
require 'optparse'

require 'glue/hash'
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 = Glue::SafeHash.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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
nitro-0.16.0 lib/nitro/session/drbserver.rb
nitro-0.17.0 lib/nitro/session/drbserver.rb
nitro-0.18.0 lib/nitro/session/drbserver.rb
nitro-0.18.1 lib/nitro/session/drbserver.rb
nitro-0.19.0 lib/nitro/session/drbserver.rb
nitro-0.20.0 lib/nitro/session/drbserver.rb