-
Notifications
You must be signed in to change notification settings - Fork 0
/
schedule_insert.php
62 lines (58 loc) · 1.1 KB
/
schedule_insert.php
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
<?php
$end = new DateTime();
$end->add(new DateInterval('PT1M'));
include "include/config.php";
include "include/functions.php";
include "include/database_functions.php";
$conn = getDatabaseConnection($dbServer, $dbUser, $dbPassword, $dbName);
if (isset($_GET['silent']))
{
$silent = boolval($_GET['silent']);
}
else
{
$silent = true;
}
if ($silent)
{
ob_start();
}
?>
<html>
<head>
<title>schedule inserting weather data</title>
</head>
<body>
<?php
echo "Scheduling started at " . date_format(new DateTime(), 'Y-m-d H:i:s'). " , silent is " . $silent . "<br/>";
?>
</body>
</html>
<?php
if ($silent)
{
echo "now running in background...";
$size = ob_get_length();
header("Content-Encoding: none");
header("Content-Length: {$size}");
header("Connection: close");
ob_end_flush();
ob_flush();
flush();
}
for ($i = 1; $i <= $selfMaxCalls; $i++)
{
// echo 'i=' . $i;
if (!is_locked($conn, "insert"))
{
call($selfUrl, $basicAuthUser, $basicAuthPassword, $silent);
}
if (new DateTime() > $end)
{
// echo 'time is up';
break;
}
usleep($sleepTimeMicros);
}
$conn->close();
?>