改名
This commit is contained in:
@@ -1,83 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: whwyy
|
||||
* Date: 2018/10/7 0007
|
||||
* Time: 2:16
|
||||
*/
|
||||
|
||||
namespace Console;
|
||||
|
||||
|
||||
use Snowflake\Abstracts\Component;
|
||||
use Swoole\Coroutine\Channel;
|
||||
use Swoole\Runtime;
|
||||
use Swoole\Timer;
|
||||
use Snowflake\Snowflake;
|
||||
|
||||
/**
|
||||
* Class Application
|
||||
* @package Console
|
||||
*/
|
||||
class Application extends Component
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $id = 'uniqueId';
|
||||
|
||||
/** @var Console */
|
||||
private $console;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$this->console = new Console();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $class
|
||||
* @throws
|
||||
*/
|
||||
public function register($class)
|
||||
{
|
||||
if (is_string($class) || is_callable($class, true)) {
|
||||
$class = Snowflake::createObject($class);
|
||||
}
|
||||
$this->console->signCommand($class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param null $kernel
|
||||
* @return string|void
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function run($kernel = null)
|
||||
{
|
||||
try {
|
||||
$kernel = make($kernel, Kernel::class);
|
||||
|
||||
Runtime::enableCoroutine(SWOOLE_HOOK_ALL);
|
||||
|
||||
$this->console->setParameters();
|
||||
$this->console->batch($kernel);
|
||||
$class = $this->console->search();
|
||||
$params = response()->send($this->console->execCommand($class));
|
||||
} catch (\Exception $exception) {
|
||||
$params = response()->send(implode("\n", [
|
||||
'Msg: ' . $exception->getMessage(),
|
||||
'Line: ' . $exception->getLine(),
|
||||
'File: ' . $exception->getFile()
|
||||
]));
|
||||
} finally {
|
||||
Timer::clearAll();
|
||||
return $params;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -96,9 +96,7 @@ class Application extends BaseApplication
|
||||
$manager = Snowflake::app()->get('console');
|
||||
$manager->setParameters($argv);
|
||||
$class = $manager->search();
|
||||
Coroutine::create(function ($manager, $class) {
|
||||
response()->send($manager->execCommand($class));
|
||||
}, $manager, $class);
|
||||
response()->send($manager->execCommand($class));
|
||||
} catch (\Throwable $exception) {
|
||||
response()->send(implode("\n", [
|
||||
'Msg: ' . $exception->getMessage(),
|
||||
|
||||
Reference in New Issue
Block a user