<?php
require 'init.php';

$process = `ps aux | grep collect/run | grep -v grep | grep -v sh | wc -l`;
$process = intval($process);
if ($process > 1)
{     
    exit;
}

// 取得需要监控的站点列表
$monitorList = Spider::getMonitorList();
$sql = 'SELECT * FROM ig_collectrun';
$runList = $db->setQueryString($sql)->find();
if (empty($runList))
{
    // 启动全新一轮
    $startList = $monitorList;
}
else
{
    // 启动已经结束的
    foreach ($runList as $run)
    {
        $list[] = $run['site'];
    }
    $startList = array_diff($monitorList, $list);
}

Updater::startMonitor($startList);