-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathpostprocess_run.php
41 lines (33 loc) · 1.35 KB
/
postprocess_run.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
<?php
// Lock file
$fp = fopen("/tmp/postprocess-runlock", "w");
if (! flock($fp, LOCK_EX | LOCK_NB)) { echo "Already running\n"; die; }
// Get script location
list($scriptPath) = get_included_files();
$basedir = str_replace("/postprocess_run.php","",$scriptPath);
require "common.php";
require "request.php";
// Load emoncms
require "/var/www/emoncms/Lib/load_emoncms.php";
include "Modules/postprocess/postprocess_model.php";
$postprocess = new PostProcess($mysqli, $redis, $feed);
$postprocess->datadir = $settings['feed']['phpfina']['datadir'];
$postprocess->get_processes("$linked_modules_dir/postprocess");
$process_classes = $postprocess->get_process_classes();
while (true) {
if ($process = $postprocess->pop_process_queue()) {
print json_encode($process)."\n";
$result = $process_classes[$process->params->process]->process($process->params);
if ($result['success']) {
print "Success: ".$result['message']."\n";
$postprocess->update_status($process->userid,$process->processid,"finished",$result['message']);
$feed->update_user_feeds_size($process->userid);
} else {
$postprocess->update_status($process->userid,$process->processid,"error",$result['message']);
print "Error: ".$result['message']."\n";
}
} else {
break;
}
sleep(1);
}