Skip to content

Commit

Permalink
Set ClosureProcess default enable start. (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
xuanyanwow authored Oct 8, 2023
1 parent f8ad497 commit d01c342
Show file tree
Hide file tree
Showing 25 changed files with 34 additions and 3 deletions.
1 change: 1 addition & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
'single_quote' => true,
'standardize_not_equals' => true,
'multiline_comment_opening_closing' => true,
'single_line_empty_body' => false,
])
->setFinder(
PhpCsFixer\Finder::create()
Expand Down
6 changes: 5 additions & 1 deletion README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,14 @@ $app = AppFactory::create();
$app->addProcess(function(){
while (true) {
sleep(1);
$this->get(StdoutLoggerInterface::class)->info('Processing...');
$this->container->get(StdoutLoggerInterface::class)->info('Processing...');
}
})->setName('nano-process')->setNums(1);

$app->addProcess(function(){
$this->container->get(StdoutLoggerInterface::class)->info('根据env判定是否需要启动进程...');
})->setName('nano-process')->setNums(1)->setEnable(\Hyperf\Support\env('PROCESS_ENABLE', true))));

$app->run();
```

Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,14 @@ $app = AppFactory::create();
$app->addProcess(function(){
while (true) {
sleep(1);
$this->get(StdoutLoggerInterface::class)->info('Processing...');
$this->container->get(StdoutLoggerInterface::class)->info('Processing...');
}
})->setName('nano-process')->setNums(1);

$app->addProcess(function(){
$this->container->get(StdoutLoggerInterface::class)->info('Determine whether the process needs to be started based on env...');
})->setName('nano-process')->setNums(1)->setEnable(\Hyperf\Support\env('PROCESS_ENABLE', true))));

$app->run();
```

Expand Down
1 change: 1 addition & 0 deletions example/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @contact [email protected]
* @license https://github.com/hyperf/nano/blob/master/LICENSE
*/

namespace Hyperf\Nano;

use Exception;
Expand Down
1 change: 1 addition & 0 deletions src/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @contact [email protected]
* @license https://github.com/hyperf/nano/blob/master/LICENSE
*/

namespace Hyperf\Nano;

use Closure;
Expand Down
1 change: 1 addition & 0 deletions src/BoundInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @contact [email protected]
* @license https://github.com/hyperf/nano/blob/master/LICENSE
*/

namespace Hyperf\Nano;

interface BoundInterface
Expand Down
1 change: 1 addition & 0 deletions src/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @contact [email protected]
* @license https://github.com/hyperf/nano/blob/master/LICENSE
*/

namespace Hyperf\Nano;

class ConfigProvider
Expand Down
1 change: 1 addition & 0 deletions src/Constant.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @contact [email protected]
* @license https://github.com/hyperf/nano/blob/master/LICENSE
*/

namespace Hyperf\Nano;

class Constant
Expand Down
1 change: 1 addition & 0 deletions src/ContainerProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @contact [email protected]
* @license https://github.com/hyperf/nano/blob/master/LICENSE
*/

namespace Hyperf\Nano;

use Hyperf\Contract\ContainerInterface;
Expand Down
1 change: 1 addition & 0 deletions src/Factory/AppFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @contact [email protected]
* @license https://github.com/hyperf/nano/blob/master/LICENSE
*/

namespace Hyperf\Nano\Factory;

use Dotenv\Dotenv;
Expand Down
1 change: 1 addition & 0 deletions src/Factory/ClosureCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @contact [email protected]
* @license https://github.com/hyperf/nano/blob/master/LICENSE
*/

namespace Hyperf\Nano\Factory;

use Closure;
Expand Down
3 changes: 2 additions & 1 deletion src/Factory/ClosureProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @contact [email protected]
* @license https://github.com/hyperf/nano/blob/master/LICENSE
*/

namespace Hyperf\Nano\Factory;

use Closure;
Expand All @@ -22,7 +23,7 @@ class ClosureProcess extends AbstractProcess
/**
* @var bool|callable
*/
private $enable;
private $enable = true;

public function __construct(ContainerInterface $container, private Closure $closure)
{
Expand Down
1 change: 1 addition & 0 deletions src/Factory/CommandFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @contact [email protected]
* @license https://github.com/hyperf/nano/blob/master/LICENSE
*/

namespace Hyperf\Nano\Factory;

use Closure;
Expand Down
1 change: 1 addition & 0 deletions src/Factory/CronFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @contact [email protected]
* @license https://github.com/hyperf/nano/blob/master/LICENSE
*/

namespace Hyperf\Nano\Factory;

use Hyperf\Contract\ContainerInterface;
Expand Down
1 change: 1 addition & 0 deletions src/Factory/ExceptionHandlerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @contact [email protected]
* @license https://github.com/hyperf/nano/blob/master/LICENSE
*/

namespace Hyperf\Nano\Factory;

use Closure;
Expand Down
1 change: 1 addition & 0 deletions src/Factory/MiddlewareFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @contact [email protected]
* @license https://github.com/hyperf/nano/blob/master/LICENSE
*/

namespace Hyperf\Nano\Factory;

use Closure;
Expand Down
1 change: 1 addition & 0 deletions src/Factory/ParameterParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @contact [email protected]
* @license https://github.com/hyperf/nano/blob/master/LICENSE
*/

namespace Hyperf\Nano\Factory;

use Closure;
Expand Down
1 change: 1 addition & 0 deletions src/Factory/ProcessFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @contact [email protected]
* @license https://github.com/hyperf/nano/blob/master/LICENSE
*/

namespace Hyperf\Nano\Factory;

use Closure;
Expand Down
1 change: 1 addition & 0 deletions src/Preset/Default.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @contact [email protected]
* @license https://github.com/hyperf/nano/blob/master/LICENSE
*/

namespace Hyperf\Nano;

use Hyperf\Server\Event;
Expand Down
1 change: 1 addition & 0 deletions src/Preset/Preset.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @contact [email protected]
* @license https://github.com/hyperf/nano/blob/master/LICENSE
*/

namespace Hyperf\Nano\Preset;

/**
Expand Down
1 change: 1 addition & 0 deletions src/Preset/SwooleCoroutine.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @contact [email protected]
* @license https://github.com/hyperf/nano/blob/master/LICENSE
*/

namespace Hyperf\Nano;

use Hyperf\Server\CoroutineServer;
Expand Down
1 change: 1 addition & 0 deletions src/Preset/Swow.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @contact [email protected]
* @license https://github.com/hyperf/nano/blob/master/LICENSE
*/

namespace Hyperf\Nano;

use Hyperf\HttpServer\Server as HttpServer;
Expand Down
1 change: 1 addition & 0 deletions tests/Cases/Http/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @contact [email protected]
* @license https://github.com/hyperf/nano/blob/master/LICENSE
*/

namespace HyperfTest\Nano\Cases\Http;

use Hyperf\Di\Container;
Expand Down
1 change: 1 addition & 0 deletions tests/Cases/Http/RouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @contact [email protected]
* @license https://github.com/hyperf/nano/blob/master/LICENSE
*/

namespace HyperfTest\Nano\Cases\Http;

use GuzzleHttp\RequestOptions;
Expand Down
1 change: 1 addition & 0 deletions tests/HttpTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* @contact [email protected]
* @license https://github.com/hyperf/nano/blob/master/LICENSE
*/

namespace HyperfTest\Nano;

use GuzzleHttp\Client;
Expand Down

0 comments on commit d01c342

Please sign in to comment.