Skip to content

Commit d01c342

Browse files
authored
Set ClosureProcess default enable start. (#67)
1 parent f8ad497 commit d01c342

25 files changed

+34
-3
lines changed

.php-cs-fixer.php

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
'single_quote' => true,
8686
'standardize_not_equals' => true,
8787
'multiline_comment_opening_closing' => true,
88+
'single_line_empty_body' => false,
8889
])
8990
->setFinder(
9091
PhpCsFixer\Finder::create()

README-CN.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,14 @@ $app = AppFactory::create();
223223
$app->addProcess(function(){
224224
while (true) {
225225
sleep(1);
226-
$this->get(StdoutLoggerInterface::class)->info('Processing...');
226+
$this->container->get(StdoutLoggerInterface::class)->info('Processing...');
227227
}
228228
})->setName('nano-process')->setNums(1);
229229

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

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,14 @@ $app = AppFactory::create();
214214
$app->addProcess(function(){
215215
while (true) {
216216
sleep(1);
217-
$this->get(StdoutLoggerInterface::class)->info('Processing...');
217+
$this->container->get(StdoutLoggerInterface::class)->info('Processing...');
218218
}
219219
})->setName('nano-process')->setNums(1);
220220

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

example/index.php

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* @contact [email protected]
1010
* @license https://github.com/hyperf/nano/blob/master/LICENSE
1111
*/
12+
1213
namespace Hyperf\Nano;
1314

1415
use Exception;

src/App.php

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* @contact [email protected]
1010
* @license https://github.com/hyperf/nano/blob/master/LICENSE
1111
*/
12+
1213
namespace Hyperf\Nano;
1314

1415
use Closure;

src/BoundInterface.php

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* @contact [email protected]
1010
* @license https://github.com/hyperf/nano/blob/master/LICENSE
1111
*/
12+
1213
namespace Hyperf\Nano;
1314

1415
interface BoundInterface

src/ConfigProvider.php

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* @contact [email protected]
1010
* @license https://github.com/hyperf/nano/blob/master/LICENSE
1111
*/
12+
1213
namespace Hyperf\Nano;
1314

1415
class ConfigProvider

src/Constant.php

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* @contact [email protected]
1010
* @license https://github.com/hyperf/nano/blob/master/LICENSE
1111
*/
12+
1213
namespace Hyperf\Nano;
1314

1415
class Constant

src/ContainerProxy.php

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* @contact [email protected]
1010
* @license https://github.com/hyperf/nano/blob/master/LICENSE
1111
*/
12+
1213
namespace Hyperf\Nano;
1314

1415
use Hyperf\Contract\ContainerInterface;

src/Factory/AppFactory.php

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* @contact [email protected]
1010
* @license https://github.com/hyperf/nano/blob/master/LICENSE
1111
*/
12+
1213
namespace Hyperf\Nano\Factory;
1314

1415
use Dotenv\Dotenv;

src/Factory/ClosureCommand.php

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* @contact [email protected]
1010
* @license https://github.com/hyperf/nano/blob/master/LICENSE
1111
*/
12+
1213
namespace Hyperf\Nano\Factory;
1314

1415
use Closure;

src/Factory/ClosureProcess.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* @contact [email protected]
1010
* @license https://github.com/hyperf/nano/blob/master/LICENSE
1111
*/
12+
1213
namespace Hyperf\Nano\Factory;
1314

1415
use Closure;
@@ -22,7 +23,7 @@ class ClosureProcess extends AbstractProcess
2223
/**
2324
* @var bool|callable
2425
*/
25-
private $enable;
26+
private $enable = true;
2627

2728
public function __construct(ContainerInterface $container, private Closure $closure)
2829
{

src/Factory/CommandFactory.php

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* @contact [email protected]
1010
* @license https://github.com/hyperf/nano/blob/master/LICENSE
1111
*/
12+
1213
namespace Hyperf\Nano\Factory;
1314

1415
use Closure;

src/Factory/CronFactory.php

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* @contact [email protected]
1010
* @license https://github.com/hyperf/nano/blob/master/LICENSE
1111
*/
12+
1213
namespace Hyperf\Nano\Factory;
1314

1415
use Hyperf\Contract\ContainerInterface;

src/Factory/ExceptionHandlerFactory.php

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* @contact [email protected]
1010
* @license https://github.com/hyperf/nano/blob/master/LICENSE
1111
*/
12+
1213
namespace Hyperf\Nano\Factory;
1314

1415
use Closure;

src/Factory/MiddlewareFactory.php

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* @contact [email protected]
1010
* @license https://github.com/hyperf/nano/blob/master/LICENSE
1111
*/
12+
1213
namespace Hyperf\Nano\Factory;
1314

1415
use Closure;

src/Factory/ParameterParser.php

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* @contact [email protected]
1010
* @license https://github.com/hyperf/nano/blob/master/LICENSE
1111
*/
12+
1213
namespace Hyperf\Nano\Factory;
1314

1415
use Closure;

src/Factory/ProcessFactory.php

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* @contact [email protected]
1010
* @license https://github.com/hyperf/nano/blob/master/LICENSE
1111
*/
12+
1213
namespace Hyperf\Nano\Factory;
1314

1415
use Closure;

src/Preset/Default.php

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* @contact [email protected]
1010
* @license https://github.com/hyperf/nano/blob/master/LICENSE
1111
*/
12+
1213
namespace Hyperf\Nano;
1314

1415
use Hyperf\Server\Event;

src/Preset/Preset.php

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* @contact [email protected]
1010
* @license https://github.com/hyperf/nano/blob/master/LICENSE
1111
*/
12+
1213
namespace Hyperf\Nano\Preset;
1314

1415
/**

src/Preset/SwooleCoroutine.php

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* @contact [email protected]
1010
* @license https://github.com/hyperf/nano/blob/master/LICENSE
1111
*/
12+
1213
namespace Hyperf\Nano;
1314

1415
use Hyperf\Server\CoroutineServer;

src/Preset/Swow.php

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* @contact [email protected]
1010
* @license https://github.com/hyperf/nano/blob/master/LICENSE
1111
*/
12+
1213
namespace Hyperf\Nano;
1314

1415
use Hyperf\HttpServer\Server as HttpServer;

tests/Cases/Http/ContainerTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* @contact [email protected]
1010
* @license https://github.com/hyperf/nano/blob/master/LICENSE
1111
*/
12+
1213
namespace HyperfTest\Nano\Cases\Http;
1314

1415
use Hyperf\Di\Container;

tests/Cases/Http/RouteTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* @contact [email protected]
1010
* @license https://github.com/hyperf/nano/blob/master/LICENSE
1111
*/
12+
1213
namespace HyperfTest\Nano\Cases\Http;
1314

1415
use GuzzleHttp\RequestOptions;

tests/HttpTestCase.php

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* @contact [email protected]
1010
* @license https://github.com/hyperf/nano/blob/master/LICENSE
1111
*/
12+
1213
namespace HyperfTest\Nano;
1314

1415
use GuzzleHttp\Client;

0 commit comments

Comments
 (0)