jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [branches/] [HotSaNIC-0.5.0-pre6/] [diagrams.pl] - Rev 34 Go to most recent revision

Compare with Previous - Blame - Download


#!/usr/bin/env perl

# $Id: diagrams.pl,v 1.6 2004/07/11 22:39:38 bernisys Exp $

# include PERL libraries
use strict;
use warnings;
use diagnostics;

# include HotSaNIC libraries
use lib "./lib";
use HotSaNICparser;

(my $VERSION = '$Revision: 1.6 $') =~ s/.*(\d+\.\d+).*/$1/;
(my $IDENTIFIER = '$Id: diagrams.pl,v 1.6 2004/07/11 22:39:38 bernisys Exp $') =~ s/.*,v (.*) \$/$1/;

# read global settings
#
my %CONFIG=HotSaNICparser::get_config("./");

my $PIDFILE=$CONFIG{VARDIR}."/run/diagram.pid";
my $PID=HotSaNICparser::get_pid($PIDFILE,"diagram");
if ($PID > 0) {
  print "diagram process already running on PID $PID\nchecking if stalled...\n";
  if (-e $PIDFILE) { 
    my $runtime=time-(stat($PIDFILE))[10];
    print "process running $runtime sec\n";
    if ($runtime > 1800) {
      print "Killing probably stalled diagram process on $PID\n";
      kill 9,$PID;
      }
    else { print "seems ok - exiting normally.\n"; exit 0; }
    }
  }

open FILE,">$PIDFILE";
print FILE $$;
close FILE;

if (! -e $CONFIG{WEBDIR}) { mkdir $CONFIG{WEBDIR},0755; }

chdir "./modules";
opendir DIR,".";
my @files=grep /[a-zA-Z]+/,readdir DIR;
closedir DIR;

foreach my $entry (sort @files) {
  if ( (-d $entry) && ($entry ne "CVS") ) {
    print "----- modules/$entry -----\n";
    if ( (index($CONFIG{SHOW},$entry) >= 0) or ($CONFIG{SHOW} eq "*") ) {
      chdir "./$entry";
      if (-e "diagrams.pl") { system "./diagrams.pl"; } elsif (-e "diagrams") { system "./diagrams"; }
      chdir "..";
      }
    else { print "Module not in SHOW - skipping...\n"; }
    }
  }

unlink $PIDFILE;


Powered by WebSVN 2.2.1