miniflux-legacy/worker.php

41 lines
1.1 KiB
PHP
Raw Permalink Normal View History

2016-05-02 04:03:21 +02:00
<?php
use Miniflux\Handler;
2016-08-25 03:17:58 +02:00
use Miniflux\Model;
use Miniflux\Session\SessionStorage;
use Pheanstalk\Pheanstalk;
2016-05-02 04:03:21 +02:00
2016-08-19 03:02:49 +02:00
require __DIR__.'/app/common.php';
2016-05-02 04:03:21 +02:00
if (php_sapi_name() !== 'cli') {
die('This script can run only from the command line.'.PHP_EOL);
}
2016-05-02 04:03:21 +02:00
$connection = new Pheanstalk(BEANSTALKD_HOST);
$session = SessionStorage::getInstance();
2016-05-02 04:03:21 +02:00
while ($job = $connection->reserveFromTube(BEANSTALKD_QUEUE)) {
$payload = unserialize($job->getData());
2016-12-27 03:49:53 +01:00
$start_time = microtime(true);
2016-12-27 03:49:53 +01:00
echo 'Processing feed_id=', $payload['feed_id'], ' for user_id=', $payload['user_id'];
$user = Model\User\get_user_by_id($payload['user_id']);
if (empty($user)) {
echo ', user not found (removed?)'.PHP_EOL;
} else {
$session->flush();
$session->setUser($user);
Handler\Feed\update_feed($payload['user_id'], $payload['feed_id']);
Model\Item\autoflush_read($payload['user_id']);
Model\Item\autoflush_unread($payload['user_id']);
2016-05-17 03:58:56 +02:00
echo ', duration='.(microtime(true) - $start_time).' seconds', PHP_EOL;
Miniflux\Helper\write_debug_file();
}
2016-12-27 03:49:53 +01:00
2016-05-02 04:03:21 +02:00
$connection->delete($job);
}