forked from CMSROMA/GUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstop.php
More file actions
108 lines (75 loc) · 2.1 KB
/
stop.php
File metadata and controls
108 lines (75 loc) · 2.1 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<html>
<head>
<title>Stopping acquisition...</title>
</head>
<body>
<?php
function isRunning($pid)
{
try {
$result = shell_exec(sprintf('ps %d', $pid));
if(count(preg_split("/\n/", $result)) > 2) {
return true;
}
} catch(Exception $e) {}
return false;
}
date_default_timezone_set('Europe/Rome');
$end_date = date('Y-m-d H:i:s');
$emulator = 0;
if( isset($_GET[emulator]) ) {
if( $_GET[emulator] == 1 ) {
echo "<font color=red size=large>ATTENTION: this is an emulator session!</font><br>";
$emulator = 1;
}
}
// define stop file
if( $emulator == 1 ) {
$daqhome = "/tmp/";
} else {
$daqhome = "/home/cmsdaq/DAQ/VMEDAQ/";
}
$stopfile = $daqhome . "/acq.stop";
if( $_POST["endrun"] ) {
//touch($stopfile);
exec("touch $stopfile", $output);
exec("chmod ug+w $stopfile", $output);
exec("chown www-data.www-data $stopfile", $output);
$endrun = $_POST["endrun"];
$pid = $_POST["daqpid"];
echo "You have requested to end run $endrun with process id $pid <br>";
echo "<br>";
echo "stopping all running processes. please wait ... <br>";
}
echo "</p>";
?>
<p>
<?php
if( file_exists($stopfile) && isRunning($pid) ) {
?>
<input type="button" value="Run <?php echo $endrun ?> in progress... please wait">
<script>
function refresh() {
window.location.reload(true);
}
setTimeout(refresh, 2000);
</script>
<?php
} else {
if( !isRunning($pid) ) {
echo "DAQ processed not running. check if run ended correctly<br>";
echo "Forcing removal of acq.stop<br>";
}
$endDate = date('Y-m-d H:i:s');
echo "run $endrun stopped at $endDate<br>";
//echo "Run Stopped.";
?>
<FORM METHOD="POST" ACTION="end.php?emulator=<?php echo $emulator;?>" NAME="end">
Reason for ending the run:<input name="fin_comment" size="250"><br>
<input type="hidden" name="endrun" value=<?php echo $run_num;?> />
<INPUT TYPE="SUBMIT" onclick=" return confirmFunc()" VALUE='End Run'>
<?php } ?>
</form>
</p>
</body>
</html>