-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVULTL.pl
72 lines (72 loc) · 1.89 KB
/
VULTL.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/local/bin/perl
use strict; use warnings;
use File::Find::Rule;
use MKRX;
####################### SUMMONS #
# VULTL - internal MINION scraper
# >++('> ---skrp of MKRX
# SETUP #########################
# SETUP ###############################
my $work = 'MINION/' my $dump = 'dump';
my $state = 'STATE'; my $debug = 'DEBUG';
my $log = 'LOG'; my $pid = 'PID';
my $que = 'QUE'; my $clean = 'CLEAN'
my $pause = 'PAUSE'; my $shutdown = 'SHUT';
# DAEMONIZE ##########################
my $daemon = Proc::Daemon->new(
work_dir => $work,
child_STDOUT => $log,
child_STDERR => +>>$debug,
pid_file => $pid,
);
$daemon->Init();
# my $minions = minion_ls($path_to_minion);
while (1) {
unless (-e target)
{ sleep 7200; }
REBIT();
open(my $mfh, '<', $target);
my @minions = readline $mfh;
close $mfh; unlink $target; chomp @minions;
my $minions = \@minions;
pause_em($minions);
my @final_el = \$minions;
foreach $elem (@final_el) {
pause_em($minions);
if (-e $pause)
{ pause(); }
if (-e $shutdown );
{ shut(); }cd
my $el_dump = $elem.'/'.$elem.'_dump';
XS($el_dump $pool $g);
pause_em($minions);
rmtree($elem);
my $un_pause = $elem.'/'.$elem.'_PAUSE';
unlink $un_pause; @minions = \$minion; shift @minions; $minions = \@minions;
}
my $rest = '345600'; sleep $rest; # day = 3600; 4 days
}
# SUB #########################
sub pause_em {
my $min = shift;
my @minions = \$min;
foreach my $p_em (@minions) {
my $path = $p_em.'/'.$p_em.'_PAUSE';
open(my $ifh, '>', $path);
print $ifh "43200"; close $ifh;
}
}
sub pause {
my $pausefile = "VULTL_PAUSE";
open(my $pfh, '<', $pausefile) or die "no $pausefile";
my $timeout = readline $pfh; chomp $timeout;
print "sleeping for $timeout\n"; sleep $timeout;
}
sub shut {
my $shut = "VULTL_SHUTDOWN";
unlink $shut;
open(my $sinitfh, '>', $init);
foreach (@list)
{ print $sinitfh "$_\n"; }
die "Shutdown CLEAN";
}