Add features to gen_site.pl manager through socket communication: freeze/unfreeze, ls and show
This commit is contained in:
parent
d422fe8b64
commit
555cf56bfe
64
gen_site.pl
64
gen_site.pl
@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
|
|
||||||
use v5.10.1;
|
use v5.12;
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use threads;
|
use threads;
|
||||||
@ -136,6 +136,25 @@ sub manage
|
|||||||
|
|
||||||
for ($cmd)
|
for ($cmd)
|
||||||
{
|
{
|
||||||
|
if (/^freeze/)
|
||||||
|
{
|
||||||
|
my $dq;
|
||||||
|
{
|
||||||
|
lock($queue);
|
||||||
|
$dq = $queue->dequeue();
|
||||||
|
if ($dq ne $cmd) {
|
||||||
|
$queue->insert(0, $dq);
|
||||||
|
$cmd = $dq;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($dq eq $cmd)
|
||||||
|
{
|
||||||
|
lock($queue);
|
||||||
|
cond_wait($queue) while $queue->pending() <= 0 || $queue->peek() !~ /^unfreeze/;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (/^all$/)
|
if (/^all$/)
|
||||||
{
|
{
|
||||||
say "Generate all teams";
|
say "Generate all teams";
|
||||||
@ -306,13 +325,40 @@ sub parse($$;$)
|
|||||||
|
|
||||||
for my $cmd ($cmds =~ /([^:]+)/g)
|
for my $cmd ($cmds =~ /([^:]+)/g)
|
||||||
{
|
{
|
||||||
my $len = length($cmd);
|
|
||||||
|
|
||||||
# Search the right position
|
|
||||||
my $i;
|
my $i;
|
||||||
for ($i = 0; $i < $queue->pending(); $i++)
|
if ($cmd =~ "^(un)?freeze")
|
||||||
{
|
{
|
||||||
last if ($len > length($queue->peek($i)));
|
$i = 0;
|
||||||
|
}
|
||||||
|
elsif ($cmd =~ "^show")
|
||||||
|
{
|
||||||
|
lock($queue);
|
||||||
|
say $chan_output "Pending queue:";
|
||||||
|
for ($i = 0; $i < $queue->pending(); $i++) {
|
||||||
|
say $chan_output "$i. $queue->peek($i)";
|
||||||
|
}
|
||||||
|
say $chan_output "empty!" if $queue->pending() == 0;
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
elsif ($cmd =~ "^ls")
|
||||||
|
{
|
||||||
|
say $chan_output "Content of $main::tmpdir:";
|
||||||
|
opendir(my $dh, $main::tmpdir) || next;
|
||||||
|
while (readdir $dh) {
|
||||||
|
say $chan_output "$_";
|
||||||
|
}
|
||||||
|
closedir $dh;
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
my $len = length($cmd);
|
||||||
|
|
||||||
|
# Search the right position
|
||||||
|
for ($i = 0; $i < $queue->pending(); $i++)
|
||||||
|
{
|
||||||
|
last if ($len > length($queue->peek($i)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
say $chan_output "Inserting $cmd at position $i/".$queue->pending();
|
say $chan_output "Inserting $cmd at position $i/".$queue->pending();
|
||||||
$queue->insert($i, $cmd);
|
$queue->insert($i, $cmd);
|
||||||
@ -371,6 +417,8 @@ sub socket_run
|
|||||||
{
|
{
|
||||||
chomp $_;
|
chomp $_;
|
||||||
parse($m, $_, $connection);
|
parse($m, $_, $connection);
|
||||||
|
print $connection "\n";
|
||||||
|
$connection->flush;
|
||||||
}
|
}
|
||||||
say "Closing socket connection; stopping thread.";
|
say "Closing socket connection; stopping thread.";
|
||||||
close $connection;
|
close $connection;
|
||||||
@ -872,6 +920,10 @@ Number of parallel fetch to perform.
|
|||||||
|
|
||||||
=over
|
=over
|
||||||
|
|
||||||
|
=item B<freeze>
|
||||||
|
|
||||||
|
Freeze the scheduler until unfreeze is sent.
|
||||||
|
|
||||||
=item B<all>
|
=item B<all>
|
||||||
|
|
||||||
Generate pages for all teams.
|
Generate pages for all teams.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user