aoolication runners

This commit is contained in:
Yuri Kuznetsov
2020-07-12 19:11:53 +03:00
parent 269f2b4850
commit 1b61205281
19 changed files with 574 additions and 118 deletions
+37 -90
View File
@@ -37,7 +37,6 @@ use Espo\Core\{
ContainerConfiguration, ContainerConfiguration,
InjectableFactory, InjectableFactory,
EntryPointManager, EntryPointManager,
CronManager,
Authentication\Authentication, Authentication\Authentication,
Api\Auth as ApiAuth, Api\Auth as ApiAuth,
Api\ErrorOutput as ApiErrorOutput, Api\ErrorOutput as ApiErrorOutput,
@@ -49,8 +48,8 @@ use Espo\Core\{
Utils\Config, Utils\Config,
Utils\Metadata, Utils\Metadata,
Utils\ClientManager, Utils\ClientManager,
Utils\Log,
ORM\EntityManager, ORM\EntityManager,
Console\CommandManager as ConsoleCommandManager,
Portal\Application as PortalApplication, Portal\Application as PortalApplication,
Loaders\Config as ConfigLoader, Loaders\Config as ConfigLoader,
Loaders\Log as LogLoader, Loaders\Log as LogLoader,
@@ -70,6 +69,8 @@ use Slim\{
Factory\AppFactory as SlimAppFactory, Factory\AppFactory as SlimAppFactory,
}; };
use ReflectionClass;
/** /**
* A central access point of the application. * A central access point of the application.
*/ */
@@ -79,6 +80,8 @@ class Application
protected $slim = null; protected $slim = null;
protected $log;
protected $loaderClassNames = [ protected $loaderClassNames = [
'config' => ConfigLoader::class, 'config' => ConfigLoader::class,
'log' => LogLoader::class, 'log' => LogLoader::class,
@@ -118,7 +121,7 @@ class Application
$route = $item['route']; $route = $item['route'];
if (!in_array($method, $crudList) && $method !== 'options') { if (!in_array($method, $crudList) && $method !== 'options') {
$GLOBALS['log']->error("Route: Method '{$method}' does not exist. Check the route '{$route}'."); $this->getLog()->error("Route: Method '{$method}' does not exist. Check the route '{$route}'.");
continue; continue;
} }
@@ -234,97 +237,46 @@ class Application
} }
/** /**
* Run cron. * Run an application through a specific runner.
* You can find runner classes in `Espo\Core\ApplicationRunners`.
*/ */
public function runCron() public function run(string $runnerName, ?object $params = null)
{ {
if ($this->getConfig()->get('cronDisabled')) { $className = $this->getRunnerClassName($runnerName);
$GLOBALS['log']->warning("Cron is not run because it's disabled with 'cronDisabled' param.");
return;
}
$this->setupSystemUser();
$this->getCronManager()->run();
}
/** if (!$className) {
* Run daemon. $this->getLog()->error("Application runner '{$runnerName}' does not exist.");
*/
public function runDaemon()
{
$maxProcessNumber = $this->getConfig()->get('daemonMaxProcessNumber');
$interval = $this->getConfig()->get('daemonInterval');
$timeout = $this->getConfig()->get('daemonProcessTimeout');
$phpExecutablePath = $this->getConfig()->get('phpExecutablePath');
if (!$phpExecutablePath) {
$phpExecutablePath = (new \Symfony\Component\Process\PhpExecutableFinder)->find();
}
if (!$maxProcessNumber || !$interval) {
$GLOBALS['log']->error("Daemon config params are not set.");
return; return;
} }
$processList = []; $class = new ReflectionClass($className);
while (true) { if ($class->getStaticPropertyValue('cli', false)) {
$toSkip = false; if (substr(php_sapi_name(), 0, 3) !== 'cli') {
$runningCount = 0; die("Application runner '{$runnerName}' can be run only via CLI.");
foreach ($processList as $i => $process) {
if ($process->isRunning()) {
$runningCount++;
} else {
unset($processList[$i]);
}
} }
$processList = array_values($processList);
if ($runningCount >= $maxProcessNumber) {
$toSkip = true;
}
if (!$toSkip) {
$process = new \Symfony\Component\Process\Process([$phpExecutablePath, 'cron.php']);
$process->setTimeout($timeout);
$process->run();
$processList[] = $process;
}
sleep($interval);
} }
if ($class->getStaticPropertyValue('setupSystemUser', false)) {
$this->setupSystemUser();
}
$runner = $this->getInjectableFactory()->create($className);
$runner->run($params);
} }
/** protected function getRunnerClassName(string $runnerName) : ?string
* Run a job by ID. A job record should exist in database.
*/
public function runJob(string $id)
{ {
$this->setupSystemUser(); $className = 'Espo\\Core\\ApplicationRunners\\' . ucfirst($runnerName);
$this->getCronManager()->runJobById($id);
}
/** if (!class_exists($className)) {
* Rebuild application. $className = $this->getMetadata()->get(['app', 'runners', $runnerName, 'className']);
*/ if (!$className || !class_exists($className)) {
public function runRebuild() return null;
{ }
$this->getDataManager()->rebuild(); }
}
/** return $className;
* Clear application cache.
*/
public function runClearCache()
{
$this->getDataManager()->clearCache();
}
/**
* Run command in Console Command framework.
*/
public function runCommand(string $command)
{
$this->setupSystemUser();
$consoleCommandManager = $this->getInjectableFactory()->create(ConsoleCommandManager::class);
return $consoleCommandManager->run($command);
} }
/** /**
@@ -354,6 +306,11 @@ class Application
return $this->container->get('injectableFactory'); return $this->container->get('injectableFactory');
} }
protected function getLog() : Log
{
return $this->container->get('log');
}
protected function getClientManager() : ClientManager protected function getClientManager() : ClientManager
{ {
return $this->container->get('clientManager'); return $this->container->get('clientManager');
@@ -369,16 +326,6 @@ class Application
return $this->container->get('config'); return $this->container->get('config');
} }
protected function getDataManager() : DataManager
{
return $this->container->get('dataManager');
}
protected function getCronManager() : CronManager
{
return $this->container->get('cronManager');
}
protected function getEntityManager() : EntityManager protected function getEntityManager() : EntityManager
{ {
return $this->container->get('entityManager'); return $this->container->get('entityManager');
@@ -0,0 +1,37 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2020 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: https://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Core\ApplicationRunners;
/**
* Runs an application.
*/
interface ApplicationRunner
{
}
@@ -0,0 +1,54 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2020 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: https://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Core\ApplicationRunners;
use Espo\Core\{
DataManager,
};
/**
* Clears an application cache.
*/
class ClearCache implements ApplicationRunner
{
use Cli;
protected $dataManager;
public function __construct(DataManager $dataManager)
{
$this->dataManager = $dataManager;
}
public function run()
{
$this->dataManager->clearCache();
}
}
@@ -0,0 +1,38 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2020 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: https://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Core\ApplicationRunners;
/**
* Can be run only via CLI.
*/
trait Cli
{
public static $cli = true;
}
@@ -0,0 +1,65 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2020 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: https://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Core\ApplicationRunners;
use Espo\Core\{
InjectableFactory,
Console\CommandManager as ConsoleCommandManager,
};
/**
* Runs a console command.
*/
class Command implements ApplicationRunner
{
use Cli;
use SetupSystemUser;
protected $injectableFactory;
public function __construct(InjectableFactory $injectableFactory)
{
$this->injectableFactory = $injectableFactory;
$this->commandManager = $this->injectableFactory->create(ConsoleCommandManager::class);
}
public function run()
{
ob_start();
$result = $this->commandManager->run($_SERVER['argv']);
if (is_string($result)) {
ob_end_clean();
echo $result;
}
}
}
@@ -0,0 +1,63 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2020 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: https://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Core\ApplicationRunners;
use Espo\Core\{
CronManager,
Utils\Config,
};
/**
* Runs cron.
*/
class Cron implements ApplicationRunner
{
use Cli;
use SetupSystemUser;
protected $cronManager;
protected $config;
public function __construct(CronManager $cronManager, Config $config)
{
$this->cronManager = $cronManager;
$this->config = $config;
}
public function run()
{
if ($this->config->get('cronDisabled')) {
$GLOBALS['log']->warning("Cron is not run because it's disabled with 'cronDisabled' param.");
return;
}
$this->cronManager->run();
}
}
@@ -0,0 +1,96 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2020 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: https://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Core\ApplicationRunners;
use Espo\Core\{
Utils\Config,
};
use Symfony\Component\Process\{
PhpExecutableFinder,
Process,
};
/**
* Runs daemon. The daemon runs the cron more often than once a minute.
*/
class Daemon implements ApplicationRunner
{
use Cli;
protected $config;
public function __construct(Config $config)
{
$this->config = $config;
}
public function run()
{
$maxProcessNumber = $this->config->get('daemonMaxProcessNumber');
$interval = $this->config->get('daemonInterval');
$timeout = $this->config->get('daemonProcessTimeout');
$phpExecutablePath = $this->config->get('phpExecutablePath');
if (!$phpExecutablePath) {
$phpExecutablePath = (new PhpExecutableFinder)->find();
}
if (!$maxProcessNumber || !$interval) {
$GLOBALS['log']->error("Daemon config params are not set.");
return;
}
$processList = [];
while (true) {
$toSkip = false;
$runningCount = 0;
foreach ($processList as $i => $process) {
if ($process->isRunning()) {
$runningCount++;
} else {
unset($processList[$i]);
}
}
$processList = array_values($processList);
if ($runningCount >= $maxProcessNumber) {
$toSkip = true;
}
if (!$toSkip) {
$process = new Process([$phpExecutablePath, 'cron.php']);
$process->setTimeout($timeout);
$process->run();
$processList[] = $process;
}
sleep($interval);
}
}
}
@@ -0,0 +1,55 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2020 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: https://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Core\ApplicationRunners;
use Espo\Core\{
CronManager,
};
/**
* Runs a job by ID. A job record should exist in database.
*/
class Job implements ApplicationRunner
{
use Cli;
use SetupSystemUser;
protected $cronManager;
public function __construct(CronManager $cronManager)
{
$this->cronManager = $cronManager;
}
public function run(object $params)
{
$this->cronManager->runJobById($params->id);
}
}
@@ -0,0 +1,54 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2020 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: https://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Core\ApplicationRunners;
use Espo\Core\{
DataManager,
};
/**
* Rebuilds an application.
*/
class Rebuild implements ApplicationRunner
{
use Cli;
protected $dataManager;
public function __construct(DataManager $dataManager)
{
$this->dataManager = $dataManager;
}
public function run()
{
$this->dataManager->rebuild();
}
}
@@ -0,0 +1,38 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2020 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: https://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Core\ApplicationRunners;
/**
* System user will be set up for an application.
*/
trait SetupSystemUser
{
public static $setupSystemUser = true;
}
@@ -37,6 +37,9 @@ use Espo\Core\{
use Espo\Core\Exceptions\Error; use Espo\Core\Exceptions\Error;
/**
* Processes console commands. A console command can be run in CLI by runnig `php command.php`.
*/
class CommandManager class CommandManager
{ {
protected $injectableFactory; protected $injectableFactory;
@@ -48,11 +51,19 @@ class CommandManager
$this->metadata = $metadata; $this->metadata = $metadata;
} }
public function run(string $command) public function run(array $argv)
{ {
$command = isset($argv[1]) ? trim($argv[1]) : null;
if (!$command) {
$msg = "Command name is not specifed.";
echo $msg . "\n";
throw new Error($msg);
}
$command = ucfirst(Util::hyphenToCamelCase($command)); $command = ucfirst(Util::hyphenToCamelCase($command));
$params = $this->getParams($_SERVER['argv']); $params = $this->getParams($argv);
$options = $params['options']; $options = $params['options'];
$flagList = $params['flagList']; $flagList = $params['flagList'];
@@ -110,6 +110,17 @@ class Application extends BaseApplication
return $routeList; return $routeList;
} }
protected function getRunnerClassName(string $runnerName) : ?string
{
$className = 'Espo\\Core\\Portal\\ApplicationRunners\\' . ucfirst($runnerName);
if (class_exists($className)) {
return $className;
}
return parent::getRunnerClassName($runnerName);
}
public function runClient() public function runClient()
{ {
$this->container->get('clientManager')->display(null, null, [ $this->container->get('clientManager')->display(null, null, [
+6 -2
View File
@@ -29,6 +29,8 @@
namespace Espo\Core\Utils\Cron; namespace Espo\Core\Utils\Cron;
use Espo\Core\Application;
class JobTask extends \Spatie\Async\Task class JobTask extends \Spatie\Async\Task
{ {
private $jobId; private $jobId;
@@ -44,9 +46,11 @@ class JobTask extends \Spatie\Async\Task
public function run() public function run()
{ {
$app = new \Espo\Core\Application(); $app = new Application();
try { try {
$app->runJob($this->jobId); $app->run('job', (object) [
'id' => $this->jobId,
]);
} catch (\Throwable $e) { } catch (\Throwable $e) {
$GLOBALS['log']->error("JobTask: Failed job run. Job id: ".$this->jobId.". Error details: ".$e->getMessage()); $GLOBALS['log']->error("JobTask: Failed job run. Job id: ".$this->jobId.". Error details: ".$e->getMessage());
} }
@@ -13,6 +13,7 @@
["app", "templateHelpers"], ["app", "templateHelpers"],
["app", "appParams"], ["app", "appParams"],
["app", "cleanup"], ["app", "cleanup"],
["app", "runners"],
["app", "auth2FAMethods", "__ANY__", "implementationClassName"], ["app", "auth2FAMethods", "__ANY__", "implementationClassName"],
["app", "auth2FAMethods", "__ANY__", "implementationUserClassName"], ["app", "auth2FAMethods", "__ANY__", "implementationUserClassName"],
["authenticationMethods", "__ANY__", "implementationClassName"] ["authenticationMethods", "__ANY__", "implementationClassName"]
+1 -4
View File
@@ -27,9 +27,6 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word. * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/ ************************************************************************/
if (substr(php_sapi_name(), 0, 3) != 'cli') die('ClearCache can be run only via CLI.');
include "bootstrap.php"; include "bootstrap.php";
$app = new \Espo\Core\Application(); (new \Espo\Core\Application())->run('clearCache');
$app->runClearCache();
+2 -8
View File
@@ -27,19 +27,13 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word. * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/ ************************************************************************/
if (substr(php_sapi_name(), 0, 3) != 'cli') exit; include "bootstrap.php";
ob_start(); ob_start();
$command = isset($_SERVER['argv'][1]) ? trim($_SERVER['argv'][1]) : null; $result = (new \Espo\Core\Application())->run('command');
if (empty($command)) exit;
include "bootstrap.php";
$app = new \Espo\Core\Application();
$result = $app->runCommand($command);
if (is_string($result)) { if (is_string($result)) {
ob_end_clean(); ob_end_clean();
echo $result; echo $result;
} }
exit;
+1 -4
View File
@@ -27,9 +27,6 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word. * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/ ************************************************************************/
if (substr(php_sapi_name(), 0, 3) != 'cli') die('Cron can be run only via CLI.');
include "bootstrap.php"; include "bootstrap.php";
$app = new \Espo\Core\Application(); (new \Espo\Core\Application())->run('cron');
$app->runCron();
+1 -4
View File
@@ -27,9 +27,6 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word. * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/ ************************************************************************/
if (substr(php_sapi_name(), 0, 3) != 'cli') die('Daemon can be run only via CLI.');
include "bootstrap.php"; include "bootstrap.php";
$app = new \Espo\Core\Application(); (new \Espo\Core\Application())->run('daemon');
$app->runDaemon();
+1 -4
View File
@@ -27,9 +27,6 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word. * these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/ ************************************************************************/
if (substr(php_sapi_name(), 0, 3) != 'cli') die('Rebuild can be run only via CLI.');
include "bootstrap.php"; include "bootstrap.php";
$app = new \Espo\Core\Application(); (new \Espo\Core\Application())->run('rebuild');
$app->runRebuild();