Changeset 14954 for misc/runpugs

Show
Ignore:
Timestamp:
12/30/06 19:07:12 (23 months ago)
Author:
andara
Message:

[runpugs]
-be kind to feather: better management of preloaded sessions.
Please test the devel version: http://feather.perl6.nl:8080/runpugs/
-fixed non-interactive runpugs, now at
http://feather.perl6.nl:8080/cgi-bin/runp6script

Location:
misc/runpugs
Files:
2 added
8 modified

Legend:

Unmodified
Added
Removed
  • misc/runpugs/cgi-bin/runpugs2

    r14733 r14954  
    2323use Web::Terminal::Settings; 
    2424use Web::Terminal::Dispatcher; 
    25 $Web::Terminal::Settings::port=2058; 
     25#$Web::Terminal::Settings::port=2058; 
    2626#push (@INC, "$wwwpath$htmlpath$project"); 
    2727 
  • misc/runpugs/data/runpugs.html

    r14885 r14954  
    168168href="http://feather.perl6.nl/~andara/runpugs/">read the documentation</a>. 
    169169</p> 
    170 <p class="copyright">&copy; Copyright 2006 by Wim Vanderbauwhede</p> 
     170<p class="copyright">&copy; Copyright 2006 by Wim.Vanderbauwhede. Contact me 
     171at gmail.com.</p> 
    171172</div> 
    172173</body> 
  • misc/runpugs/htdocs/index.html

    r14851 r14954  
    44<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
    55<title>Run Perl 6 Now -- in your browser!</title> 
     6<link rel="shortcut icon" href="favicon.ico" type="image/x-icon"> 
     7<link rel="icon" href="favicon.ico" type="image/x-icon"> 
    68<link rel="stylesheet" type="text/css" href="runpugs.css"> 
    79</head> 
     
    2022<tt>runpugs</tt>:</p><ul><li>try the <a 
    2123href="http://feather.perl6.nl:8080/runpugs/">interactive session</a> 
    22 with <em>command history</em></li> <li>or <a 
    23 href="http://feather.perl6.nl:8080/cgi-bin/runpugs2?ia=0">run a full Perl 6 
    24 script</a> in <em>non-interactive</em> mode.</li></ul> 
     24with command history, fast startup and response and a persistent interface; </li>  
     25<li>or <a 
     26href="http://feather.perl6.nl:8080/cgi-bin/runp6script">run a full Perl 6 
     27script</a> in <em>non-interactive</em> mode.</li> 
     28 
     29</ul> 
    2530 
    2631<h2>Instructions</h2> 
     
    7479<code><a href="http://svn.pugscode.org/pugs/misc/runpugs">/misc/runpugs</a></code>. 
    7580<p>Thank you for trying <tt>pugs</tt> and <tt>runpugs</tt>!</p> 
    76 <p class="copyright">&copy; Copyright 2006 by Wim Vanderbauwhede</p> 
     81<p class="copyright">&copy; Copyright 2006 by Wim.Vanderbauwhede. Contact me 
     82at gmail.com</p> 
    7783</div> 
    7884</body></html> 
  • misc/runpugs/htdocs/runpugs.css

    r14743 r14954  
    7676} 
    7777#outputwindow { 
    78     height:20ex; 
     78    height:40ex; 
    7979} 
    8080#editorwindow { 
  • misc/runpugs/htdocs/runpugs/index.html

    r14930 r14954  
    1616<input name="ia" value="1" type="hidden"> 
    1717<input name="action" value="runpugs" type="hidden"> 
    18 <input id="rel" value="0" name="reldev" checked="checked" type="radio" 
     18<input id="rel" value="0" name="reldev" type="radio" 
    1919onClick="set_version()"><label for="rel">Release version</label>&nbsp;&nbsp; 
    20 <input id="dev" value="1" name="reldev" type="radio" onClick="set_version()"><label for="dev">Development version</label> 
     20<input id="dev" value="1" name="reldev" checked="checked" type="radio" onClick="set_version()"><label for="dev">Development version</label> 
    2121<div id="termwindow"> 
    2222<textarea id="cmd" name="cmd" rows="20" cols="80" wrap="virtual" 
     
    3131<p>This live web terminal runs the <a href="http://www.pugscode.org/">Pugs</a> 
    3232interpreter for <a href="http://dev.perl.org/perl%206/">Perl&nbsp;6</a>. 
     33<p>This is the development version, featuring asynchronous JavaScript, 
     34mod_perl and preloaded pugs sessions.</p> 
    3335Please <a href="http://feather.perl6.nl/%7Eandara/runpugs/">read the documentation</a>. 
    3436</p> 
    35 <p class="copyright">&copy; Copyright 2006 by Wim Vanderbauwhede</p> 
     37<p class="copyright">&copy; Copyright 2006 by Wim.Vanderbauwhede. Contact me @ gmail.com<./p> 
    3638</div> 
    3739</body></html> 
  • misc/runpugs/lib/Web/Terminal/Server3.pm

    r14930 r14954  
    3535#our $session_counter  = 0; 
    3636my %sessions         = ();    # holds the session objects 
    37 my @sessions_stack     = 1 .. $Web::Terminal::Settings::nsessions; 
    38 my @sessions_stack_app = (); 
     37my @sessions_stack     = 1 .. $Web::Terminal::Settings::nsessions; # holds counters for new sessions 
     38my @sessions_stack_app = (); # holds counters for idle sessions per app 
    3939my $v = 1 - $Web::Terminal::Settings::daemon; 
    4040 
     
    188188        my $ia  = shift; 
    189189        my $cmd = shift; 
     190    if($ia!=0) { 
    190191        if (   scalar( keys %terminals ) > $Web::Terminal::Settings::nsessions 
    191192                or scalar(@sessions_stack) == 0 ) 
     
    270271                                        # Every time a free session is taken, create a new session 
    271272                    # if the number of free sessions is low 
    272                     if ( @{ $sessions_stack_app[$app] }<2) { 
     273                    if ( @{ $sessions_stack_app[$app] } < $Web::Terminal::Settings::npreloaded_sessions[$app]-1) { 
    273274                                        # we use a SIGUSR2 to the child for this 
    274275                                        kill 'USR2', $pid or die $!; 
     
    291292                } 
    292293        } 
     294    } else { # non-interactive 
     295        print "Non-interactive $id\n" if $v; 
     296            print "$app $ia $id $cmd\n" if $v; 
     297                my $term = new 
     298            Web::Terminal::Server::Session(app=>$app,ia=>$ia,id=>$id,cmds=>$cmd); 
     299            $term->{called}=time; 
     300            $term->{ip}=$ip; 
     301            my $output= $term->{'output'}; 
     302                $term->DESTROY(); 
     303            return $output; 
     304    } 
    293305}    # of termhandler 
    294306 
     
    344356 
    345357sub timeout() { 
    346         my $now = time(); 
     358        # Cleaning up timed-out sessions 
     359    my $now = time(); 
    347360        for my $id ( keys %terminals ) { 
    348361                if ( exists $terminals{$id} ) { 
     
    361374                } 
    362375        } 
     376    # Keep the number of preloaded sessions low 
     377    # There is no reason to have more than npreloaded_sessions sessions preloaded and idle 
     378    #Clean up the @sessions_stack_app for each $app: 
     379 
     380    for my $app ( 0 .. @Web::Terminal::Settings::commands - 1 ) { 
     381        while(@{ $sessions_stack_app[$app] } > 
     382        $Web::Terminal::Settings::npreloaded_sessions[$app]+1){ 
     383            my $idle_session_counter=shift @{ $sessions_stack_app[$app] }; 
     384            # now actally kill that session! 
     385            push @sessions_stack, $idle_session_counter; 
     386            $sessions{$idle_session_counter}->DESTROY(); 
     387            delete $sessions{$idle_session_counter}; 
     388        } 
     389    } 
    363390} 
    364391 
  • misc/runpugs/lib/Web/Terminal/Settings.pm

    r14930 r14954  
    7676our $tmp_path='/home/andara/apache/data/tmp/'; 
    7777our $log_path='/home/andara/apache/data/log/'; 
    78 our $daemon=0; 
     78our $daemon=1; 
    7979our $port=2057; 
    8080our $host='localhost'; 
  • misc/runpugs/perl/runpugs3.pl

    r14930 r14954  
    9898    my $sessionid=shift; 
    9999    my $ip=shift; 
    100     my $dev=$query->param('reldev')||0; 
    101     $dev=$dev*1; 
     100    my $dev=$query->param('reldev');#||0; 
     101    if ($dev!=0){ 
     102    $dev=1; 
     103    } 
    102104    my $devc='checked'; 
    103105    my $relc='';