Пример #1
0
 public function robotsAction(Request $request)
 {
     $host = $request->headers->get('host');
     $cacheId = 'robots_txt';
     $env = $this->get('kernel')->getEnvironment();
     $cache = new \Doctrine\Common\Cache\FilesystemCache($_SERVER['DOCUMENT_ROOT'] . '/../app/cache/' . $env . '/sys/' . $host . '/etc/');
     //$cache = new \Doctrine\Common\Cache\ApcCache();
     if ($fooString = $cache->fetch($cacheId)) {
         $response = unserialize($fooString);
     } else {
         $site = $this->getSite();
         if (!$site) {
             $response = $this->render('CMFTemplateBundle:Status:404.html.twig');
             $response->setStatusCode(404);
             return $response;
         }
         $response = new Response();
         $response->headers->set('Content-Type', 'text/plain');
         $response->sendHeaders();
         $response->setContent($site['robots_txt']);
         $cache->save($cacheId, serialize($response));
     }
     return $response;
 }
Пример #2
0
        $app->render('jobs_class_distribution.ctp', array('class' => $resqueStat->getJobsRepartionStats($limit)));
    } catch (\Exception $e) {
        $app->error($e);
    }
})->conditions(array('limit' => '\\d+'));
/**
 * Return a list of scheduled jobs count grouped by time
 * Used to populate the cal-heatmap
 */
$app->get('/api/scheduled-jobs/stats/:start/:end', function ($start, $end) use($app) {
    $app->response()->header("Content-Type", "application/json");
    try {
        $cacheId = $start . $end;
        $cacheDriver = new \Doctrine\Common\Cache\FilesystemCache(CACHE . DS . 'scheduled-jobs' . DS . 'stats', '.cache');
        if ($cacheDriver->contains($cacheId)) {
            $jobs = $cacheDriver->fetch($cacheId);
        } else {
            $resqueSchedulerStat = new ResqueBoard\Lib\ResqueSchedulerStat();
            $jobs = $resqueSchedulerStat->getScheduledJobsCount((int) $start, (int) $end + 60, true);
            $jobs = json_encode($jobs);
            if ($start < $end && $end < time()) {
                $cacheDriver->save($cacheId, $jobs);
            }
        }
        echo $jobs;
    } catch (\Exception $e) {
        $app->error($e);
    }
})->conditions(array('start' => '\\d+', 'end' => '\\d+'));
$app->get('/api/scheduled-jobs/:start/:end', function ($start, $end) use($app) {
    $app->response()->header("Content-Type", "application/json");