Changeset a168f52 in tol for tolsh/tolsh.vfs/lib/app-tolsh/tolsh.tcl
- Timestamp:
- Dec 6, 2010, 9:22:59 PM (16 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- 4e49e21
- Parents:
- 10a207c
- File:
-
- 1 edited
-
tolsh/tolsh.vfs/lib/app-tolsh/tolsh.tcl (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tolsh/tolsh.vfs/lib/app-tolsh/tolsh.tcl
r10a207c ra168f52 166 166 set options(runmode) "slave" 167 167 } 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 168 171 if {$options(runmode) ne "" && $options(runmode) ne "shared"} { 169 172 puts "Replacing previous run mode '$options(runmode)' with 'shared'" 170 173 } 171 174 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 172 179 } else { 173 180 append delayed_msg "\nignoring unknown option: '$item'" … … 444 451 } elseif {$options(runmode) eq "shared"} { 445 452 puts "runmode=shared" 446 run_as_shared 453 run_as_shared $tolcomm_dir 447 454 448 455 } elseif {$options(runmode) eq "slave"} { … … 456 463 package require tolserver 457 464 458 clone465 set shared_port [ clone ] 459 466 tolserver::start -port $options(server,port) \ 467 -shport $shared_port \ 460 468 -logfile [file join $tolcomm_dir "tolserver.log"] \ 461 469 -compile $options(compile) … … 463 471 } 464 472 473 proc ::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 465 488 proc ::tolsh::clone {} { 466 489 variable options … … 471 494 lappend tolsh $::argv0 472 495 } 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 & 474 502 after 5000 ;# wait for data sharing are created by 'shared' 475 503 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 508 proc ::tolsh::run_as_shared { tolcomm_dir } { 480 509 package require tolshared 481 482 tolshared::start 510 variable options 511 512 tolshared::start $options(shared,port) $tolcomm_dir 483 513 } 484 514 485 proc ::tolsh::run_as_slave { tolcomm_dir} {515 proc ::tolsh::run_as_slave { tolcomm_dir } { 486 516 variable options 487 517 package require tolslave 488 518 489 tolslave::start -port $options(server,port) \519 tolslave::start -port $options(server,port) -shport $options(shared,port) \ 490 520 -logfile [file join $tolcomm_dir "tolslave.log"] 491 521 vwait __forever__
Note: See TracChangeset
for help on using the changeset viewer.
