From 9457b450799a13d1e835418227a48a7c4c6e6f89 Mon Sep 17 00:00:00 2001 From: Manuel Penschuck Date: Tue, 29 Jan 2013 21:40:01 +0100 Subject: [PATCH] Cleanup --- web/cts_gui | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/web/cts_gui b/web/cts_gui index 944ca85..da94026 100755 --- a/web/cts_gui +++ b/web/cts_gui @@ -21,6 +21,8 @@ sub execServerAndMonitor { sleep 1; + $SIG{ 'INT' } = \&clean_up; + # Exec Monitor while(1) { system "./cts $quiteParam m $htdocsDumpDir"; @@ -50,6 +52,7 @@ HELP } + # Gather and check parameters if (!$ENV{'DAQOPSERVER'}) { print "ERROR: Missing DAQOPSERVER enviroment variable !\n"; @@ -78,6 +81,12 @@ HELP my $quiteParam = $quite ? '--quite ' : ''; + sub clean_up { + print "\n\n\n CLEAN UP\n"; + system "rm -rf $sharedDir $htdocsDumpDir"; + exit; + }; + # If this script was started within xterm - start monitor if ($monitor) { execServerAndMonitor $host, $port, $htdocsDumpDir, $quiteParam; @@ -85,8 +94,8 @@ HELP } # Setup shared memory - print "Trying to kill processes 'cts' and 'dhttpi'\n"; - system 'pkill "^(cts|dhttpi)$"'; +# print "Trying to kill processes 'cts' and 'dhttpi'\n"; +# system 'pkill "^(cts|dhttpi)$"'; print "\n\nTry to map monitoring files to shared memory (if it failes, no harm is done. Only the HDD has to work a little bit more)\n"; @@ -94,21 +103,18 @@ HELP system "rm -rf $sharedDir"; system "mkdir -p $sharedDir"; - system( "ln -s $sharedDir $htdocsDumpDir" ) || system ("mkdir -p $htdocsDumpDir"); + system "chmod 777 $sharedDir"; + system( "ln -s $sharedDir $htdocsDumpDir || mkdir -p $htdocsDumpDir"); system( "cp htdocs/layout/empty_plot.png $htdocsDumpDir/plot.png" ); system( "cp htdocs/layout/empty_plot.png $htdocsDumpDir/plotshort.png" ); - $SIG{ 'INT' } = sub { - print "\n\n\n CLEAN UP\n"; - system "rm -rf $sharedDir $htdocsDumpDir"; - exit; - }; - # Start Monitor (either directly or indirectly via XTERM)" print "\n\nStart monitoring script"; if ($openxterm) { - system("xterm -fn '-misc-fixed-medium-r-normal--8-*-*-*-*-*-iso8859-15' +sb -geometry 200x100 +aw +bc -bg LightCoral -j -e '$0 --monitor --port=$port $quiteParam'"); + exec("xterm -fn '-misc-fixed-medium-r-normal--8-*-*-*-*-*-iso8859-15' +sb -geometry 200x100 +aw +bc -bg LightCoral -j -e '$0 --monitor --port=$port $quiteParam'"); } else { execServerAndMonitor $host, $port, $htdocsDumpDir, $quiteParam; - } \ No newline at end of file + } + + clean_up; -- 2.43.0