test and fix cron issue

This commit is contained in:
aaronchen2k
2020-01-16 10:20:26 +08:00
parent f32d591d7e
commit 2ce41370aa
3 changed files with 13 additions and 21 deletions
-1
View File
@@ -890,7 +890,6 @@ class ciModel extends model
->beginIF(!empty(whr))->andWhere('(' . $whr . ')')->fi()
->orderBy(id)
->fetchAll();
$repos[''] = '';
return $repos;
}
+6 -5
View File
@@ -177,6 +177,12 @@ class cron extends control
$this->common->loadConfigFromDB();
foreach($parsedCrons as $id => $cron)
{
// TODO: debug cron dow = 2-6/1
$temp = $now > $cron['time'];
if ($id == 5 && $temp) {
error_log($temp . ' = ' . date_format($now, "Y/m/d H:i:s") . ' > ' . date_format($cron['time'], "Y/m/d H:i:s"));
}
$cronInfo = $this->cron->getById($id);
/* Skip empty and stop cron.*/
if(empty($cronInfo) or $cronInfo->status == 'stop') continue;
@@ -187,11 +193,6 @@ class cron extends control
if($now > $cron['time'])
{
// TODO: debug cron dow = 2-6/1
if ($id == 16) {
$id = 16;
}
$this->cron->changeStatus($id, 'running');
$parsedCrons[$id]['time'] = $cron['cron']->getNextRunDate();
+7 -15
View File
@@ -87,11 +87,9 @@ class gitModel extends model
$this->setLogRoot();
$this->setRestartFile();
foreach($this->repos as $name => $repo)
foreach($this->repos as $repo)
{
$this->printLog("begin repo $name");
$repo = (object)$repo;
$repo->name = $name;
$this->printLog("begin repo $repo->id");
if(!$this->setRepo($repo)) return false;
$this->pull();
@@ -140,9 +138,9 @@ class gitModel extends model
/**
* Pull codes from remote repo.
*
* @param $repoRoot
* @param $repo
*/
public function pull($repo)
public function pull($repo = '')
{
if (!empty($repo)) {
$repoRoot = $repo->path;
@@ -205,21 +203,15 @@ class gitModel extends model
$gitRepos = [];
$paths = [];
// 有了库管理,忽略配置里的库
foreach($repoObjs as $repoInDb)
{
if(strtolower($repoInDb->SCM) === 'git' && !in_array($repoInDb->path, $gitRepos)) {
$gitRepos[] = array(path => $repoInDb->path, encoding => 'utf-8');
$gitRepos[] = array(id=>$repoInDb->id, path => $repoInDb->path, encoding => 'utf-8');
$paths[] = $repoInDb->path;
}
}
foreach($this->config->git->repos as $repoInConfig)
{
if(!empty($repoInConfig['path']) && !in_array($repoInConfig['path'], $paths)) {
$gitRepos[] = $repoInConfig;
}
}
if(!$gitRepos)
{
echo "You must set one git repo.\n";
@@ -261,7 +253,7 @@ class gitModel extends model
$this->setClient($repo);
if(empty($this->client)) return false;
$this->setLogFile($repo->name);
$this->setLogFile($repo->id);
$this->setRepoRoot($repo);
return true;
}