Changeset a168f52 in tol


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

Location:
tolsh/tolsh.vfs/lib
Files:
3 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__
  • tolsh/tolsh.vfs/lib/tolcomm/tolserver.tcl

    r10a207c ra168f52  
    452452  array set options {
    453453    -port 6669
     454    -shport 20458
    454455    -logfile ""
    455456    -compile ""
    … …  
    467468  }
    468469 
    469   server_attach_data
     470  server_attach_data $options(-shport)
    470471
    471472  log "debug" "shared_tasks(init)=$options(-compile)"
    … …  
    474475}
    475476
    476 proc ::tolserver::server_attach_data {} {
     477proc ::tolserver::server_attach_data { shared_port } {
    477478  package require tequila
    478479  global shared_tasks
    … …  
    480481  global shared_finish
    481482
    482   tequila::open localhost 20458
     483  tequila::open localhost $shared_port
    483484  tequila::attach shared_tasks
    484485  tequila::attach shared_state
  • tolsh/tolsh.vfs/lib/tolcomm/tolshared.tcl

    r10a207c ra168f52  
    2222#
    2323###############################################################################
    24 proc ::tolshared::start {} {
     24proc ::tolshared::start { port datadir } {
    2525  global tqs_info
    2626  package require Mk4tcl
    … …  
    2828
    2929  puts "::tolshared::start"
    30   mk::file open tqs tequilas.dat -nocommit
     30  # OJO: este archivo hay abrirlo en algun directorio controlado
     31  mk::file open tqs [ file join $datadir tequilas.${port}.dat ] -nocommit
    3132  set tqs_info(verbose) 0     ;# default logging is off
    3233  TqsTimer ""                 ;# default commit timer is 30 seconds
    33   tqsRun 20458                ;# default port is 20458
     34  tqsRun $port                ;# default port is 20458
    3435}
Note: See TracChangeset for help on using the changeset viewer.