jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [trunk/] [diagrams.pl] - Blame information for rev 20

 

Line No. Rev Author Line
11simandl#!/usr/bin/env perl
2use strict;
3use warnings;
4use diagnostics;
5 
6use lib "./lib";
7use HotSaNICparser;
8 
9# read global settings
10#
11my %CONFIG=HotSaNICparser::get_config("./");
12 
13my $PIDFILE=$CONFIG{VARDIR}."/run/diagram.pid";
14my $PID=HotSaNICparser::get_pid(0,$PIDFILE,"diagram"); # <<<--- second parameter not functional yet!
15if ($PID > 0) {
16 print "diagram process already running on PID $PID\nchecking if stalled...\n";
17 if (-e $PIDFILE) {
18 my $runtime=time-(stat($PIDFILE))[10];
19 print "process running $runtime sec\n";
20 if ($runtime > 1800) {
21 print "Killing probably stalled diagram process on $PID\n";
22 kill 9,$PID;
23 }
24 else { print "seems ok - exiting normally.\n"; exit 0; }
25 }
26 }
27 
28open FILE,">$PIDFILE";
29print FILE $$;
30close FILE;
31 
32my $LOGNAME=$CONFIG{LOGDIR}."/diagram.log";
33 
34if (! -e $CONFIG{WEBDIR}) { mkdir $CONFIG{WEBDIR},0755; }
35 
36if ( ($CONFIG{DIAGRAMLOG} ne "all") && (-e $LOGNAME) ) { unlink $LOGNAME; }
37 
38chdir "./modules";
39opendir DIR,".";
40my @files=grep /[a-zA-Z]+/,readdir DIR;
41closedir DIR;
42 
43foreach my $entry (@files) {
44 if ( (-d $entry) && ($entry ne "CVS") ) {
45 print "----- modules/$entry -----\n";
46 if (index($CONFIG{SHOW},$entry) >= 0) {
47 chdir "./$entry";
48 if (-e "diagrams.pl") { system "./diagrams.pl"; } elsif (-e "diagrams") { system "./diagrams"; }
49 chdir "..";
50 }
51 else { print "Module not in SHOW - skipping...\n"; }
52 }
53 }
54 
55unlink $PIDFILE;
56 

Powered by WebSVN 2.2.1