Changeset 16218 for misc/runpugs

Show
Ignore:
Timestamp:
05/07/07 16:26:38 (19 months ago)
Author:
andara
Message:

[runpugs]
- Session.pm: now with Moose
- Session startup handling now more robust
- Repl.pm: a very simple mini-REPL for testing

Location:
misc/runpugs
Files:
4 added
6 modified

Legend:

Unmodified
Added
Removed
  • misc/runpugs/bin/multi_client_model.pl

    r15833 r16218  
    66use strict; 
    77 
    8 use threads;           # pull in threading routines 
     8#use threads;           # pull in threading routines 
    99 
    1010use lib '../lib/'; 
     
    1919our $nclients_serial=500; 
    2020 
     21#for my $i (0..$n_threads-1) { 
     22#       $threads[$i]=threads->create("client_session",$i); 
     23#} 
     24 
     25# program exits when first thread exits 
     26my $pid; 
    2127for my $i (0..$n_threads-1) { 
    22         $threads[$i]=threads->create("client_session",$i); 
    23 } 
    24  
    25 # program exits when first thread exits 
    26 $threads[0]->join();  
     28        if($pid=fork()) { 
     29                print "Spawned $i\n";  
     30        } elsif (defined $pid) { # Child 
     31                        print "Running $i\n"; 
     32                        &client_session($i); 
     33                        exit(0); 
     34                } else { 
     35                        die "Fork failed!"; 
     36                } 
     37} 
     38print "Parent: done creating clients."; 
     39sleep 3600; 
     40#$threads[0]->join();  
    2741 
    2842 
     
    108122print "$i:WARNING2: $cmd<>$reply\n";# if $v; 
    109123#if ($reply eq '0') { 
    110 system("./killall_perl"); 
     124#system("./killall_perl"); 
     125kill 9,getppid(); 
    111126exit() ; 
    112127#} 
     
    118133} elsif ($abort) { 
    119134&send_cmd(':A',$id,$ip,$app); 
    120 } #�therwise do nothing, server should time the session out 
     135} #�otherwise do nothing, server should time the session out 
    121136my $w_log= rand($w_max_log)+$w_min_log; 
    122137my $wait=int(2**$w_log); 
    123138print "\n$i:Waiting for $wait seconds...\n" if $v; 
    124139sleep $wait;  
    125 } #�nd of nclients_serial loop 
     140} #�end of nclients_serial loop 
    126141 
    127142} 
  • misc/runpugs/bin/termdispatcher.pl

    r14512 r16218  
    66# 
    77use lib '../lib/'; 
    8 use WebTerminal::Dispatcher; 
     8use Web::Terminal::Settings; 
     9use Web::Terminal::Dispatcher; 
     10#$Web::Terminal::Settings::port=2058; 
    911 
    1012 
    1113my $id=$ARGV[0]||-1; 
    12 my $cmd=$ARGV[1] || 'my $a='.$id.';say "Hello, $a";'; 
    13 #my $cmd='my $a='.$id.';say "Hello, $a";'; 
    14 my $prompt='pugs> '; 
     14my $cmd=$ARGV[1] || 'print "hello\n";say "there";print 4'; 
    1515print "Sending msg $id: $cmd\n"; 
    1616my $ip="127.0.0.1"; 
    17 my $dev=1; 
    18 my $reply = &WebTerminal::Dispatcher::send($id,$ip,$dev,$prompt.$cmd); 
     17(my $reply,my $prompt,my $histref) = 
     18&Web::Terminal::Dispatcher::send($id,$ip,1,1,$cmd); 
    1919print $reply; 
     20print "\nHistory\n"; 
     21for my $entry (@{$histref}) { 
     22print "\t$entry\n"; 
     23} 
    2024 
  • misc/runpugs/bin/termserv.pl

    r14233 r16218  
    11#!/usr/bin/perl 
     2use strict; 
     3use warnings; 
     4#BEGIN { 
     5#$ENV{PERLIO}= ":utf8"; 
     6#} 
     7#use utf8; 
     8 
    29use warnings; 
    310use strict; 
    4 use utf8; 
     11 
    512use lib '../lib/'; 
    6 use WebTerminal::Server; 
    7 my $host = 'localhost'; 
    8 my $port = 2057; 
     13use Web::Terminal::Server; 
     14use  Web::Terminal::Settings; 
     15$Web::Terminal::Settings::port=2059; 
    916$ENV{PUGS_SAFEMODE}=1; 
    10 &WebTerminal::Server::run($host,$port); 
     17my $v=1-$Web::Terminal::Settings::daemon; 
     18print "Starting server\n" if $v; 
     19&Web::Terminal::Server::run(); 
    1120 
  • misc/runpugs/lib/Web/Terminal/Server.pm

    r16056 r16218  
    458458sub create_session { 
    459459        my $app = shift; 
    460 my $session_number=-3; 
     460        my $session_number=-3; 
    461461        if ( $n_sessions[$app] < $n_max[$app] ) { 
    462462                # Yes, there is room to create a new session 
     
    476476                } else { 
    477477                        # Something went wrong, failed to create a new session 
     478                        print "Something went wrong, failed to create a new session:\n"; 
     479                        print $new_session->{'error'}; 
     480                        print $new_session->{'output'}; 
     481                         
    478482                        # push session number back onto stack 
    479483                        push @{ $session_numbers_stack[$app] }, $session_number; 
     
    484488                $session_number= -2;        # max nsessions reached 
    485489        } 
    486         print "+++ Created session $session_number ($app): tot:$n_sessions[$app]; active: $n_active_sessions[$app];inactive: $n_inactive_sessions[$app]\n" if $v; 
    487         print "+++ Actual occupancy $session_number ($app): tot:",scalar keys %{$sessions[$app]},"; active: ", scalar keys %{$active_sessions[$app]},";inactive: ",scalar @{$inactive_sessions[$app]}," ;free: ",scalar @{$session_numbers_stack[$app]},"\n" if $v; 
     490        print "\n+++ Created session $session_number ($app): tot:$n_sessions[$app]; active: $n_active_sessions[$app];inactive: $n_inactive_sessions[$app]\n" if $v; 
     491        print "+++ Occupancy for $session_number ($app): tot:",scalar keys %{$sessions[$app]},"; active: ", scalar keys %{$active_sessions[$app]},";inactive: ",scalar @{$inactive_sessions[$app]}," ;free: ",scalar @{$session_numbers_stack[$app]},"\n" if $v; 
    488492        assert($n_sessions[$app]==$n_inactive_sessions[$app]+$n_active_sessions[$app]); 
    489493        assert(scalar(keys %{$sessions[$app]})==scalar( keys %{$active_sessions[$app]})+scalar( @{$inactive_sessions[$app]})); 
     
    660664sub init_sessions { 
    661665        for my $app ( 0 .. @Web::Terminal::Settings::commands - 1 ) { 
     666 
    662667                @{ $session_numbers_stack[$app] } = 1 .. $n_max[$app]; 
    663668                $n_inactive_sessions[$app] = 0; 
     
    668673                   
    669674if (&sane($app)) { 
     675                        print "Creating sessions for $app\n" if $v; 
    670676                for my $i ( 1 .. $Web::Terminal::Settings::npreloaded_sessions[$app] ) { 
    671677            my $ret = &create_session($app); 
    672                         print $ret>0?'OK: $ret':'NOK',': #sesssions: ', scalar( @{ $inactive_sessions[$app] } ), ' for app ', 
     678                        print $ret>0?'OK: $ret':"NOK: $ret",': #sesssions: ', scalar( @{ $inactive_sessions[$app] } ), ' for app ', 
    673679                          $app, "\n" 
    674680                          if $v; 
    675681                } 
    676682        assert(scalar(@{ $inactive_sessions[$app] })==$Web::Terminal::Settings::npreloaded_sessions[$app]); 
    677         } 
    678     } 
     683        } else { 
     684                print "App $app is not sane. Skipped.\n" if $v;  
     685} 
     686} 
    679687}    # END of init_sessions() 
    680688#------------------------------------------------------------------------------ 
    681 # check if command is sane (FSDO sane) 
     689# Check if command is sane (FSDO sane) 
     690# This should be part of settings.  
    682691sub sane { 
    683692    my $app=shift; 
    684693    my $cmd=$Web::Terminal::Settings::commands[$app]; 
    685694    $cmd=~s/^.*nice\s+//; # de-nice 
     695    if ($cmd !~/pugs/) { 
     696        return 1; 
     697    } else { 
    686698    my $reply=`PUGS_SAFEMODE=1 $cmd -e \"print 42\" 2>/dev/null`; 
    687699    if ($reply==42) { 
     
    689701    } else { 
    690702        return 0; 
    691     } 
     703    }} 
    692704} 
    693705#------------------------------------------------------------------------------- 
     
    755767                          Web::Terminal::Dispatcher::send( 0, '127.0.0.1', 1, 1, 
    756768                                                                          'Web::Terminal::Server::Sessions.clean-up' ); 
    757                         print "call_clean_up() call returned: cleaned up <$ret> sessions\n" if $v; 
     769                                                                  if ($v) { 
     770                                                                          if($ret=~/[a-z]/) { 
     771                        print "call_clean_up() call returned: $ret\n"; 
     772                                                                          } else { 
     773                        print "call_clean_up() call returned: cleaned up <$ret> sessions\n"; 
     774                } 
     775                } 
    758776                          #( $ret < 1 ) ? "Nothing to clean up" : "OK", "\n" if $v; 
    759777                 
  • misc/runpugs/lib/Web/Terminal/Server/Session.pm

    r15408 r16218  
    33use vars qw( $VERSION ); 
    44$VERSION='0.3.0'; 
    5 use strict; 
    6 use utf8; 
     5use Moose; 
     6#use strict; 
     7#use utf8; 
    78use lib '.','../../..'; 
    89use Web::Terminal::Settings; 
     
    1415$SIG{CHLD}='IGNORE'; 
    1516 
    16 my $v=(1-$Web::Terminal::Settings::daemon)*(1-$Web::Terminal::Settings::test); 
    17 ## Constructor 
    18 sub new { 
    19         my $invocant = shift; 
    20         my $class    = ref($invocant) || $invocant; 
    21         my $self     = {@_}; 
     17my $v=0*(1-$Web::Terminal::Settings::daemon)*(1-$Web::Terminal::Settings::test); 
     18 
    2219    my $prompt ='/'.$Web::Terminal::Settings::prompt.'/'; 
    23     $self->{'prompt'}=$prompt; 
    24     $self->{'error'}=0; 
    25     $self->{'recent'}=[]; 
    26     print "Starting pugs session for ",$self->{'id'},"\n" if $v;  
     20    has 'prompt' => (is=>'rw',isa=>'Str', default => $prompt); 
     21    has 'error' => (is=>'rw',isa=>'Int',default=>0); 
     22        has 'output' => (is=>'rw',isa=>'Str');     
     23    has 'recent'=> (is=>'rw',isa=>'ArrayRef',default=>sub {[]}); 
     24    has 'id' => (is=>'ro',isa=>'Str'); 
     25    has 'ip' => (is=>'ro',isa=>'Str'); 
     26    has 'app' => (is=>'ro',isa=>'Int'); 
     27    has 'ia' => (is=>'ro',isa=>'Int'); 
     28    has 'cmds' => (is=>'ro',isa=>'Str'); 
     29        has 'pugs' => (is=>'rw',isa=>'Str'); 
     30    has 'pty' => (is=>'rw',isa=>'Any'); 
     31    has 'pid' => (is=>'rw',isa=>'Int'); 
     32     
     33    sub BUILD { 
     34        my $self=shift; 
     35    print "Starting pugs session for ",$self->id,"\n" if $v;  
    2736        ## Start pugs 
    28     my $app=$self->{'app'}; 
     37    my $app=$self->app; 
    2938    my $command=$Web::Terminal::Settings::commands[$app]; 
    3039    if (not $Web::Terminal::Settings::test) { 
    31     if ($self->{'ia'}==0) { 
     40    if ($self->ia==0) { 
    3241        #1. Create a file with the content of $cmd using $id.p6 for name, store in data 
    33         my $id=$self->{'id'}; 
    34         open(P6,">$Web::Terminal::Settings::tmp_path/$id.p6") or ($self->{'error'}=1); 
    35         if($self->{'error'}==0) { 
    36         print P6 $self->{'cmds'}; 
     42        my $id=$self->id; 
     43        open(P6,">$Web::Terminal::Settings::tmp_path/$id.p6") or $self->error(1); 
     44        if($self->error==0) { 
     45        print P6 $self->cmds; 
    3746        close P6; 
    3847            $command.=" $Web::Terminal::Settings::tmp_path/$id.p6"; 
     
    4049    } 
    4150        ( $self->{'pty'},$self->{'pid'} ) = &spawn($command);    # spawn() defined below 
    42     if ( $self->{'pty'}==-1 and  $self->{'pid'}==0) { 
     51    if ( $self->pty==-1 and  $self->pid==0) { 
    4352        print "There was a problem starting pugs. Please try again later.\n" 
    4453        if $v; 
    45         $self->{'output'}= "\nThere was a problem starting pugs. Please try again later."; 
    46         $self->{'error'}=1; 
    47         if ($self->{'ia'}==0) { 
    48             my $id=$self->{'id'}; 
     54        $self->output("\nThere was a problem starting pugs. Please try again later."); 
     55        $self->error(1); 
     56        if ($self->ia==0) { 
     57            my $id=$self->id; 
    4958            unlink "$Web::Terminal::Settings::tmp_path/$id.p6"; 
    5059        } 
    5160    } else { 
    5261        ## Create a Net::Telnet object to perform I/O on pugs's tty. 
     62        print "Pugs started successfully. Creating Net::Telnet object as session handler...\n" if $v; 
    5363        use Net::Telnet; 
    5464        $self->{'pugs'} = new Net::Telnet( 
    55                 -fhopen => $self->{'pty'}, 
     65                -fhopen => $self->pty, 
    5666                -timeout => $Web::Terminal::Settings::timeout_call, 
    5767                -prompt => $prompt, 
     
    6474        $self->{'pugs'} ="Test flag is set -- no session started for $command."; 
    6575    } 
    66         bless($self,$class); 
     76        print "Reading Pugs startup message...\n" if $v; 
    6777    my $m=$self->readlines(); 
    6878      if ($self->{'error'}==1 and not $Web::Terminal::Settings::test) { 
     
    7888          $self->{'pugs'}->close(); 
    7989        } 
    80         $self->{'output'}= $m;  
    81  
     90        $self->{'output'}= $m; 
     91        print "\nStatus is ",($self->{'error'}==1)?'ERROR':'OK',"\n" if $v;  
     92print "Returning with output:\n",$m,"\n\n" if $v; 
    8293        return $self; 
    8394} # END of new() constructor method 
     95 
     96 
     97 
     98### Constructor 
     99#sub new { 
     100#       my $invocant = shift; 
     101#       my $class    = ref($invocant) || $invocant; 
     102#       my $self     = {@_}; 
     103#    my $prompt ='/'.$Web::Terminal::Settings::prompt.'/'; 
     104#    $self->{'prompt'}=$prompt; 
     105#    $self->{'error'}=0; 
     106#    $self->{'recent'}=[]; 
     107#    print "Starting pugs session for ",$self->{'id'},"\n" if $v;  
     108#       ## Start pugs 
     109#    my $app=$self->{'app'}; 
     110#    my $command=$Web::Terminal::Settings::commands[$app]; 
     111#    if (not $Web::Terminal::Settings::test) { 
     112#    if ($self->{'ia'}==0) { 
     113#        #1. Create a file with the content of $cmd using $id.p6 for name, store in data 
     114#        my $id=$self->{'id'}; 
     115#        open(P6,">$Web::Terminal::Settings::tmp_path/$id.p6") or ($self->{'error'}=1); 
     116#        if($self->{'error'}==0) { 
     117#        print P6 $self->{'cmds'}; 
     118#        close P6; 
     119#            $command.=" $Web::Terminal::Settings::tmp_path/$id.p6"; 
     120#        } 
     121#    } 
     122#       ( $self->{'pty'},$self->{'pid'} ) = &spawn($command);    # spawn() defined below 
     123#    if ( $self->{'pty'}==-1 and  $self->{'pid'}==0) { 
     124#        print "There was a problem starting pugs. Please try again later.\n" 
     125#        if $v; 
     126#        $self->{'output'}= "\nThere was a problem starting pugs. Please try again later."; 
     127#        $self->{'error'}=1; 
     128#        if ($self->{'ia'}==0) { 
     129#            my $id=$self->{'id'}; 
     130#            unlink "$Web::Terminal::Settings::tmp_path/$id.p6"; 
     131#        } 
     132#    } else { 
     133#       ## Create a Net::Telnet object to perform I/O on pugs's tty. 
     134#       print "Pugs started successfully. Creating Net::Telnet object as session handler...\n" if $v; 
     135#       use Net::Telnet; 
     136#       $self->{'pugs'} = new Net::Telnet( 
     137#               -fhopen => $self->{'pty'}, 
     138#               -timeout => $Web::Terminal::Settings::timeout_call, 
     139#               -prompt => $prompt, 
     140#               -telnetmode      => 0, 
     141#               -cmd_remove_mode => 0, 
     142#       ); 
     143#    } 
     144#    } else { 
     145#       $self->{'pid'}=42; 
     146#       $self->{'pugs'} ="Test flag is set -- no session started for $command."; 
     147#    } 
     148#       bless($self,$class); 
     149#       print "Reading Pugs startup message...\n" if $v; 
     150#    my $m=$self->readlines(); 
     151#    #my $m=$self->write(''); 
     152#      if ($self->{'error'}==1 and not $Web::Terminal::Settings::test) { 
     153#          # should close the TTY 
     154#          $self->{'pty'}->close() unless ($self->{'pty'}==-1); 
     155#          $self->{'pugs'}->close(); 
     156#      } 
     157#        if ($self->{'ia'}==0 and not $Web::Terminal::Settings::test) { 
     158#        my $id=$self->{'id'}; 
     159#        unlink "$Web::Terminal::Settings::tmp_path/$id.p6"; 
     160#          # should close the TTY 
     161#          $self->{'pty'}->close() unless ($self->{'pty'}==-1); 
     162#          $self->{'pugs'}->close(); 
     163#        } 
     164#       $self->{'output'}= $m; 
     165#       print "\nStatus is ",($self->{'error'}==1)?'ERROR':'OK',"\n" if $v;  
     166#print "Returning with output:\n",$m,"\n\n" if $v; 
     167#       return $self; 
     168#} # END of new() constructor method 
    84169#------------------------------------------------------------------------------ 
    85170sub DESTROY { 
    86171    my $obj = shift; 
    87172    if (not $Web::Terminal::Settings::test) { 
     173        if (defined $obj->{'pty'}) { 
    88174    $obj->{'pty'}->close(); 
    89175     $obj->{'pty'}->close_slave(); 
     176        } 
     177        if (defined $obj->{'pugs'}) { 
    90178      $obj->{'pugs'}->close(); 
    91       if($obj->{'pid'}>10){ 
     179        } 
     180      if(defined $obj->{'pid'} and $obj->{'pid'}>10){ 
    92181          kill 9,$obj->{'pid'}; 
    93182      } 
     
    114203    $pugs->errmode(sub {kill 9,$obj->{'pid'};}); 
    115204 
    116         $pugs->print($cmd); 
     205        $pugs->print($cmd) unless $cmd eq ''; 
    117206        while ($i<$Web::Terminal::Settings::nlines) { 
    118207                my $line = $pugs->getline; 
     
    156245#------------------------------------------------------------------------------ 
    157246# Could be considered private; 
    158 # TODO: unifiy with write() 
     247# Only used by the constructor 
     248# The tacit assumption is that the MOTD is never too long 
    159249sub readlines { 
    160250        my $obj = shift; 
    161251        my $ps = ''; 
    162         my $i     = 1; 
     252#       my $i     = 1; 
    163253        my $lline = ''; 
    164254        if (not $Web::Terminal::Settings::test) { 
    165255    my $pugs=$obj->{'pugs'}; 
    166256    $pugs->errmode(sub {kill 9,$obj->{'pid'}; }); 
    167         while ($i<$Web::Terminal::Settings::nlines) { 
    168     my $char=''; 
     257#        my $prev=0; 
     258#       while ($i<$Web::Terminal::Settings::nlines) { 
     259#    my $char=''; 
    169260    my $line=''; 
    170     my $j=0; 
    171     while ($char ne "\n" and ($j<$Web::Terminal::Settings::nchars)) { 
    172     $char=$pugs->get(); 
    173     $j++; 
    174     last if $char eq ''; 
    175     $line.=$char; 
    176     last if $line eq $Web::Terminal::Settings::prompt; 
    177     } 
    178         print $line if $v; 
    179         if ($j>=$Web::Terminal::Settings::nchars-1) { 
    180         $line.="Generated output is limited to $Web::Terminal::Settings::nchars characters. Aborted.\n"; 
    181        $obj->{pugs}->close(); 
    182         kill 9, $obj->{'pid'}; 
    183         $obj->{'error'}=1; 
    184         $lline .= $line; 
    185         last; 
    186         } 
     261#    my $j=0; 
     262 
     263#    while ($char ne "\n" and ($j<$Web::Terminal::Settings::nchars)) { 
     264#    #$char=$pugs->get();# 
     265#    $char=getc $obj->{'pty'}; 
     266#    #if ($prev>0) { 
     267#    #print ord($char),"\t:char\n" if $v; 
     268#    #} 
     269#    #if (ord($char)!=27) {              
     270#    $j++; 
     271#    last if $char eq ''; 
     272#    $line.=$char; 
     273#   # print "{$line}\n"; 
     274#    last if $line =~/${Web::Terminal::Settings::prompt}$/; 
     275#    #} else {die;$prev=1;} 
     276#    } 
     277   
     278        ($line, $ps)=$pugs->waitfor(String=>$Web::Terminal::Settings::prompt); 
     279          $pugs->buffer_empty(); # maybe redundant, but play safe    
     280#       my @chars=split('',$line); 
     281#       for my $char(@chars) { 
     282#               print ord($char),"\n"; 
     283#       } 
     284           
     285        #$line=~s/....$//; 
     286       #print "L:<",$line,">" if $v; 
     287        #print "P:<",$ps,">" if $v; 
     288     #   if ($line=~/Prelude/i){$prev++}; 
     289     #die if (($line=~/${Web::Terminal::Settings::prompt}/) and ($prev>1)); 
     290     
     291#        if ($j>=$Web::Terminal::Settings::nchars-1) { 
     292#        $line.="Generated output is limited to $Web::Terminal::Settings::nchars characters. Aborted.\n"; 
     293#       $obj->{pugs}->close(); 
     294#        kill 9, $obj->{'pid'}; 
     295#        $obj->{'error'}=1; 
     296#        $lline .= $line; 
     297#        last; 
     298#        } 
    187299        my $msg=$pugs->errmsg; 
    188300            if($msg=~/timed/) { 
     
    200312        } 
    201313        $msg=''; 
    202         if ( ($line =~ /$Web::Terminal::Settings::prompt_pattern/ or 
    203         ($line=~/$Web::Terminal::Settings::quit_pattern/)) and $i > 1 ) { $ps = $1; last } 
     314#        if ( ($line =~ /$Web::Terminal::Settings::prompt_pattern/ or 
     315#        ($line=~/$Web::Terminal::Settings::quit_pattern/)) and $i > 1 ) { $ps = $1; last } 
    204316                $lline .= $line unless $line =~ 
    205317        /$Web::Terminal::Settings::prompt_pattern/; 
    206                 $i++; 
     318#               $i++; 
    207319        last if $line eq ''; 
    208         } 
    209    if ($i>=$Web::Terminal::Settings::nlines-1) { 
    210        $obj->{pugs}->close(); 
    211         kill 9, $obj->{'pid'}; 
    212         $lline.="Generated output is limited to $Web::Terminal::Settings::nlines lines. Aborted.\n"; 
    213         $obj->{'error'}=1; 
    214     } 
     320#       } 
     321#   if ($i>=$Web::Terminal::Settings::nlines-1) { 
     322#       $obj->{pugs}->close(); 
     323#        kill 9, $obj->{'pid'}; 
     324#        $lline.="Generated output is limited to $Web::Terminal::Settings::nlines lines. Aborted.\n"; 
     325#        $obj->{'error'}=1; 
     326#    } 
     327     
    215328        } else { 
    216329                $lline="Test flag is set -- readlines() called."; 
     
    235348      }; 
    236349      # 
    237     binmode $pty, ":utf8";  
     350    #binmode $pty, ":utf8";  
    238351        ## Execute the program in another process. 
    239352        unless ( $pid = fork ) {    # child process 
     
    250363                ## Associate process with a new controlling terminal. 
    251364                $tty    = $pty->slave; 
    252         binmode $tty, ":utf8"; 
     365        #binmode $tty, ":utf8"; 
    253366                $tty_fd = $tty->fileno; 
    254367                close $pty; 
     
    258371                open STDOUT, ">&$tty_fd" or ($error=1);#die $!; 
    259372                open STDERR, ">&STDOUT"  or ($error=1);#die $!; 
    260         binmode STDIN, ":utf8"; 
    261         binmode STDOUT, ":utf8"; 
    262         binmode STDERR, ":utf8"; 
     373        #binmode STDIN, ":utf8"; 
     374        #binmode STDOUT, ":utf8"; 
     375        #binmode STDERR, ":utf8"; 
    263376                close $tty; 
    264377 
     
    285398Web::Terminal::Server::Session -- Session object to encapsulate terminal 
    286399application. 
    287 Requires Net::Telnet. 
     400Requires Net::Telnet, Moose. 
    288401 
    289402=head1 SYNOPSIS 
     
    305418This module provides a Session object. The object encapsulates the 
    306419actual terminal session. The session is configured via L<Settings.pm>. 
    307 The object's C<new> method takes following arguments: 
     420The object's constructor takes following arguments: 
    308421    id: a string identifying the session 
    309422    app: an integer indicating the version of the terminal application to 
     
    330443=head1 COPYRIGHT 
    331444 
    332 Copyright (c) 2006. Wim Vanderbauwhede. All rights reserved. 
     445Copyright (c) 2006,2007 Wim Vanderbauwhede. All rights reserved. 
    333446 
    334447This program is free software; you can redistribute it and/or modify 
  • misc/runpugs/lib/Web/Terminal/Settings.pm

    r16055 r16218  
    6666my $rel_root='/home/andara/pugs-rel'; 
    6767my $dev_root='/home/andara/pugs-dev'; 
     68my $rel_lib="-I$rel_root/blib6/lib"; 
     69my $dev_lib="-I$dev_root/blib6/lib"; 
     70 
     71$ulimit=''; 
     72$nice='';#/bin/nice'; 
     73$pugs='/usr/bin/pugs'; 
     74$rel_root='/usr/bin'; 
     75$dev_root='/usr/bin'; 
     76$rel_lib=''; 
     77$dev_lib=''; 
    6878 
    6979our @commands=( 
    70 "$ulimit $nice $rel_root/pugs -I$rel_root/blib6/lib", 
    71 "$ulimit $nice $dev_root/pugs -I$dev_root/blib6/lib" 
     80"$ulimit $nice $rel_root/pugs $rel_lib", 
     81"$ulimit $nice $dev_root/pugs $dev_lib", 
     82"perl ./perl_repl.pl" 
    7283); 
    7384 
     
    7586our $appname='runpugs'; 
    7687our $prompt='pugs> '; 
     88#$prompt='perl> '; 
    7789our $prompt_pattern='(^(pugs|\.\.\.\.)>\s+)'; 
    7890our $quit_pattern='^Leaving\ pugs\.'; 
     
    99111 
    100112our $restart_parent=0; # restart parent server from child if 1 
    101 our $server="$bin_path/termserv4.pl"; # used to restart parent server from child 
     113our $server="$bin_path/termserv.pl"; # used to restart parent server from child 
    102114 
    103115our $nsessions=50; # obsolete 
    104 our @n_max=(20,50); 
     116our @n_max=(20,50,5); 
    105117our $nsessions_ip=10;  
    106 our @npreloaded_sessions=(5,10);  
     118our @npreloaded_sessions=(5,10,2);  
    107119our @n_inactive_max=@npreloaded_sessions; 
    108 our @n_inactive_min=(2,5); 
     120our @n_inactive_min=(2,5,0); 
    109121 
    110122our $timeout_idle=90; # was 600 
    111 our $timeout_call=30; #  was 30