Ignore:
Timestamp:
Dec 6, 2010, 9:22:59 PM (16 years ago)
Author:
Jorge Pérez <josp.jorge@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
4e49e21
Parents:
10a207c
Message:

refs #1028, tequila server is started on the first available port starting from port number 20458.

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@2747 be4846ae-f051-483a-831f-b64e7d08527f

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tolsh/tolsh.vfs/lib/app-tolsh/tolsh.tcl

    r10a207c ra168f52  
    166166        set options(runmode) "slave"
    167167      } elseif {$opt eq "shared"} {
     168        # the next argument is the port number
     169        set options(shared,port) [lindex $cmdline [expr {$i+1}]]
     170        incr i
    168171        if {$options(runmode) ne "" && $options(runmode) ne "shared"} {
    169172          puts "Replacing previous run mode '$options(runmode)' with 'shared'"
    170173        }
    171174        set options(runmode) "shared"
     175      }  elseif {$opt eq "shport"} {
     176        # the next argument is the port number
     177        set options(shared,port) [lindex $cmdline [expr {$i+1}]]
     178        incr i
    172179      } else {
    173180        append delayed_msg "\nignoring unknown option: '$item'"
    … …  
    444451  } elseif {$options(runmode) eq "shared"} {
    445452    puts "runmode=shared"
    446     run_as_shared    
     453    run_as_shared $tolcomm_dir
    447454 
    448455  } elseif {$options(runmode) eq "slave"} {
    … …  
    456463  package require tolserver
    457464
    458   clone
     465  set shared_port [ clone ]
    459466  tolserver::start -port $options(server,port) \
     467    -shport $shared_port \
    460468    -logfile [file join $tolcomm_dir "tolserver.log"] \
    461469    -compile $options(compile)
    … …  
    463471}   
    464472
     473proc ::tolsh::find_shared_port { port } {
     474  puts "::tolsh::find_shared_port $port"
     475  set i 0
     476  while { $i < 100 } {
     477    if { [ catch { socket localhost $port } fd ] } {
     478      puts "find_shared_port OK = $port"
     479      return $port
     480    }
     481    incr port
     482    incr i
     483  }
     484  puts "find_shared_port FAIL!"
     485  return 0
     486}
     487
    465488proc ::tolsh::clone {} {
    466489  variable options
    … …  
    471494    lappend tolsh $::argv0
    472495  }
    473   eval exec $tolsh -shared &
     496  set shared_port [ find_shared_port 20458 ]
     497  if { !$shared_port } {
     498    puts "::tolsh::clone: could not find a valid port for shared data"
     499    exit
     500  }
     501  eval exec $tolsh -shared $shared_port &
    474502  after 5000            ;# wait for data sharing are created by 'shared'
    475503  puts "exec slave"
    476   eval exec $tolsh -slave $options(server,port) &
    477 }
    478 
    479 proc ::tolsh::run_as_shared {} {
     504  eval exec $tolsh -slave $options(server,port) -shport $shared_port &
     505  return $shared_port
     506}
     507
     508proc ::tolsh::run_as_shared { tolcomm_dir } {
    480509  package require tolshared
    481 
    482   tolshared::start
     510  variable options
     511
     512  tolshared::start $options(shared,port) $tolcomm_dir
    483513}   
    484514
    485 proc ::tolsh::run_as_slave {tolcomm_dir} {
     515proc ::tolsh::run_as_slave { tolcomm_dir } {
    486516  variable options
    487517  package require tolslave
    488518
    489   tolslave::start -port $options(server,port) \
     519  tolslave::start -port $options(server,port) -shport $options(shared,port) \
    490520    -logfile [file join $tolcomm_dir "tolslave.log"]
    491521  vwait __forever__
Note: See TracChangeset for help on using the changeset viewer.