fix
This commit is contained in:
parent
6db4e4252b
commit
1ce2058830
|
@ -1,27 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace dominion\cron;
|
||||
|
||||
|
||||
use yii\base\BootstrapInterface;
|
||||
use yii\i18n\PhpMessageSource;
|
||||
|
||||
|
||||
class Bootstrap implements BootstrapInterface
|
||||
{
|
||||
|
||||
/** @inheritdoc */
|
||||
public function bootstrap($app)
|
||||
{
|
||||
var_dump(22222); die();
|
||||
if (!isset($app->get('i18n')->translations['user*']))
|
||||
{
|
||||
$app->get('i18n')->translations['user*'] = [
|
||||
'class' => PhpMessageSource::className(),
|
||||
'basePath' => __DIR__ . '/messages',
|
||||
'sourceLanguage' => 'ru-RU'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
10
Module.php
10
Module.php
|
@ -21,4 +21,14 @@ class Module extends \yii\base\Module
|
|||
|
||||
// custom initialization code goes here
|
||||
}
|
||||
public function bootstrap($app)
|
||||
{
|
||||
if ($app instanceof \yii\console\Application) {
|
||||
$app->controllerMap[$this->id] = [
|
||||
'class' => 'dominion\cron\console\MoleController',
|
||||
'module' => $this,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @link https://www.kuvalda.ru/
|
||||
* @copyright
|
||||
* @license
|
||||
*/
|
||||
|
||||
namespace dominion\cron\commands;
|
||||
|
||||
use yii\console\Controller;
|
||||
use yii\console\ExitCode;
|
||||
use dominion\cron\models\MoleTask;
|
||||
|
||||
/**
|
||||
* Запуск агента по расписанию
|
||||
*
|
||||
* @author Rybkin Sasha <ribkin@dominion.ru>
|
||||
* @since 0.1
|
||||
*/
|
||||
class MoleController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Запуск всех агентов для проекта yii из mole_task
|
||||
* @return int Exit code
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$filePatch = __DIR__.'/../runtime/lock.lock';
|
||||
if(!file_exists($filePatch))
|
||||
{
|
||||
$fp = fopen($filePatch, "w");
|
||||
fwrite($fp, "");
|
||||
fclose($fp);
|
||||
}
|
||||
$file = fopen($filePatch, 'r+');
|
||||
|
||||
if (flock($file, LOCK_EX | LOCK_NB))
|
||||
{
|
||||
$model = new MoleTask;
|
||||
$tasks = $model->getAllTask();
|
||||
foreach ($tasks as $task)
|
||||
{
|
||||
try
|
||||
{
|
||||
$task->dateStart = date('Y-m-d H:i:s');
|
||||
$task->save();
|
||||
$class = 'app\commands\\' . $task->controller;
|
||||
if (class_exists($class))
|
||||
{
|
||||
$control = new $class($task->controller, 'product');
|
||||
$control->actionIndex(unserialize($task->params));
|
||||
}
|
||||
$task->dateEnd = date('Y-m-d H:i:s');
|
||||
$task->completed = 1;
|
||||
$task->save();
|
||||
} catch (\yii\elasticsearch\Exception $ex)
|
||||
{
|
||||
$task->dateStart = null;
|
||||
$task->save();
|
||||
print_r($ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ExitCode::OK;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
|
||||
var_dump(22222);
|
||||
return [
|
||||
'sourcePath' => __DIR__ . '/../',
|
||||
'messagePath' => __DIR__,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
return [
|
||||
"ID" => 'wwww',
|
||||
"ID" => 'wwww111',
|
||||
'Task List' => 'Список задач'
|
||||
];
|
|
@ -19,8 +19,7 @@ use yii\widgets\Pjax;
|
|||
* @var \yii\data\ActiveDataProvider $dataProvider
|
||||
* @var \dektrium\user\models\UserSearch $searchModel
|
||||
*/
|
||||
$this->title = Yii::t('app', 'User List');
|
||||
$this->params['breadcrumbs'][] = ['label' => Yii::t('user', 'Manage users'), 'url' => ['']];
|
||||
$this->title = Yii::t('mole', 'Task List');
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="wrapper wrapper-content project-manager">
|
||||
|
@ -32,9 +31,7 @@ $this->params['breadcrumbs'][] = $this->title;
|
|||
'filterModel' => $searchModel,
|
||||
'layout' => "{items}\n{pager}",
|
||||
'columns' => [
|
||||
[
|
||||
'attribute' => 'id',
|
||||
],
|
||||
'id',
|
||||
|
||||
[
|
||||
'class' => 'yii\grid\ActionColumn',
|
||||
|
|
Loading…
Reference in New Issue