Module: R2CORBA::INS

Defined in:
lib/corba/svcs/ins/ins.rb,
lib/corba/svcs/ins/cos_naming.rb,
lib/corba/svcs/ins/naming_service.rb

Defined Under Namespace

Classes: BindingIterator, Controller, NamingContext, Service

Constant Summary collapse

INS_VERSION_MAJOR =
0.freeze
INS_VERSION_MINOR =
1.freeze
INS_VERSION_RELEASE =
1.freeze
'Copyright (c) 2011-2013 Remedy IT Expertise BV, The Netherlands'.freeze
IS_WIN32 =
(RUBY_PLATFORM =~ /win32/ || RUBY_PLATFORM =~ /mingw32/ || ENV['OS'] =~ /windows/i) ? true : false
IS_JRUBY =
defined?(JRUBY_VERSION)
OPTIONS =
{
  :piddir => Dir.getwd,
  :iorfile => 'ins.ior',
  :debug => 0,
  :logdir => nil,
  :threads => 5,
  :orbprop => {},
  :port => 0,
}
COMMANDS =
[
:start,
:stop,
:restart,
:status,
:help,
:version
]
@@daemons_installed =
false
@@command =
nil

Class Method Summary collapse

Class Method Details

.commandObject



382
383
384
# File 'lib/corba/svcs/ins/ins.rb', line 382

def INS.command
  @@command
end

.daemons_installedObject



39
40
41
# File 'lib/corba/svcs/ins/ins.rb', line 39

def INS.daemons_installed
  @@daemons_installed
end

.parse_argObject



386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
# File 'lib/corba/svcs/ins/ins.rb', line 386

def INS.parse_arg
  script_name = File.basename($0, '.bat')
  if not script_name =~ /rins/
    script_name = "ruby "+$0
  end

  @@command = ARGV.shift.to_sym unless ARGV.empty?
  unless COMMANDS.include?(@@command)
    STDERR.puts "ERROR: Invalid command [#{command}]!\n"+
                "Usage: #{script_name} #{COMMANDS.join('|')} [options]\n"
    exit 1
  end

  # extract -ORBxxx aguments
  f_ = false
  ARGV.collect! { |a|
    if f_
      f_ = false
      OPTIONS[:orbprop] << a
      nil
    else
      f_ = /^-ORB/ =~ a
      OPTIONS[:orbprop] << a if f_
      f_ ? nil : a
    end
  }.compact!

  case @@command
  when :help
    puts "Usage: #{script_name} #{COMMANDS.join('|')} [options]\n"
    puts "\n"
    puts "       #{script_name} #{(COMMANDS - [:help, :version]).join('|')} --help\n"
    puts "          provides help for the specified command\n\n"
    exit
  when :version
    puts "R2CORBA Interoprable Naming Service (INS) #{INS_VERSION_MAJOR}.#{INS_VERSION_MINOR}.#{INS_VERSION_RELEASE}"
    puts INS_COPYRIGHT
    puts ''
    exit
  when :start, :restart
    ARGV.options do |opts|
        opts.banner = "Usage: #{script_name} start [options]"

        opts.separator ""

        opts.on("-i FILE", "--ior=FILE", String,
                "Specifies filename (incl. path) to write IOR to.",
                "Default: ./ins.ior") { |v| OPTIONS[:iorfile]=v }
        unless IS_WIN32
          opts.on("-p DIR", "--pid=DIR", String,
                  "Specifies path to write pidfile to.",
                  "Default: ./") { |v| OPTIONS[:piddir]=v }
          unless IS_JRUBY
            opts.on("-o DIR", "--output=DIR", String,
                    "Specifies filename to write logfile to.",
                    "Default: <piddir>") { |v| OPTIONS[:logdir]=v }
          end
        else
          opts.on("-o DIR", "--output=DIR", String,
                  "Specifies path to write logfile to.",
                  "Default: ./") { |v| OPTIONS[:logdir]=v }
        end
        opts.on("-l PORTNUM", "--listen=PORTNUM", Integer,
                "Specifies port number for service endpoint.",
                "Default: none") { |v| OPTIONS[:port]=v }
        if (IS_JRUBY or R2CORBA::TAO::RUBY_THREAD_SUPPORT)
          opts.on("-t THREADNUM", "--threads=THREADNUM", Integer,
                  "Specifies (minimum) number of threads for service.",
                  "Default: 5") { |v| OPTIONS[:threads]=v }
        end

        unless IS_JRUBY || !INS.daemons_installed
          opts.on("-d", "--daemon",
                  "Run as daemon.",
                  "Default: off") { |v| OPTIONS[:daemon]=v }
        end
        opts.on("-v", "--verbose",
                "Run verbose.",
                "Default: off") { |v| OPTIONS[:verbose]=v }

        opts.on("--debug=LVL", Integer,
                "Specifies debug level.",
                "Default: 0") { |v| OPTIONS[:debug]=v }

        opts.separator ""

        opts.on("-h", "--help",
                "Show this help message.") { puts opts; puts; exit }

        opts.parse!
    end
    OPTIONS[:iorfile] = File.expand_path(OPTIONS[:iorfile])
  when :stop, :status
    ARGV.options do |opts|
        opts.banner = "Usage: #{script_name} stop [options]"

        opts.separator ""

        unless IS_WIN32
          opts.on("-p DIR", "--pid=DIR", String,
                  "Specifies path where pidfile is stored.",
                  "Default: ./") { |v| OPTIONS[:piddir]=v }
        end

        unless @@command == 'status'
          OPTIONS[:daemon] = true unless IS_JRUBY || !INS.daemons_installed
          opts.on("--[no-]daemon",
                  "Do not run in daemon mode.",
                  "Default: #{OPTIONS[:daemon] ? 'on' : 'off'}") { |v| OPTIONS[:daemon]=v }
        end
        opts.on("-v", "--verbose",
                "Run verbose.",
                "Default: off") { |v| OPTIONS[:verbose]=v }

        opts.separator ""

        opts.on("-h", "--help",
                "Show this help message.") { puts opts; puts; exit }

        opts.parse!
    end
  when :install
  when :remove
  end
  OPTIONS[:piddir] = File.expand_path(OPTIONS[:piddir]) if OPTIONS[:piddir]
  OPTIONS[:logdir] = File.expand_path(OPTIONS[:logdir]) if OPTIONS[:logdir]
end

.runObject



514
515
516
517
518
# File 'lib/corba/svcs/ins/ins.rb', line 514

def INS.run
  self.parse_arg()

  Controller.new(OPTIONS).send(self.command)
end