function init($worker) { Redis::setCacheServer(get_option_value($worker->config, 'resources.cache', '127.0.0.1:6379')); Redis::setQueueServer(get_option_value($worker->config, 'resources.queue', '127.0.0.1:6379')); $worker->tarthTimerLastTime = 0; $currentTime = time(); $minBacktrackTime = $currentTime - MAX_BACKTRACK_SECONDS; //读取上次执行到的时间 $dir = get_option_value($worker->config, 'main.working_dir', '/tmp'); $worker->tarthTimerLastTimeFile = "{$dir}/timer-last-{$worker->index}"; if (file_exists($worker->tarthTimerLastTimeFile)) { $worker->tarthTimerLastTime = intval(file_get_contents($worker->tarthTimerLastTimeFile)); } if ($minBacktrackTime > $worker->tarthTimerLastTime) { $worker->tarthTimerLastTime = $minBacktrackTime; } elseif ($worker->tarthTimerLastTime > $currentTime) { $worker->tarthTimerLastTime = $currentTime; } }
function init($worker) { Redis::setCacheServer(get_option_value($worker->config, 'resources.cache', '127.0.0.1:6379')); Redis::setQueueServer(get_option_value($worker->config, 'resources.queue', '127.0.0.1:6379')); }
<?php require_once __DIR__ . '/../vendor/autoload.php'; \Tarth\Tool\Redis::setCacheServer('127.0.0.1:6379'); \Tarth\Tool\Redis::setQueueServer('127.0.0.1:6379'); $task = \Tarth\Tool\Task::createApiTask('http://alleria.mcp.wap.grid.sina.com.cn/test/normal'); echo \Tarth\Tool\Task::exec();