代码热重启进程

Testing Is Documentation

tests/Protocol/Process/HotOverloadTest.php代码热重启进程 - 图1

监听某些目录,当代码发生变化,重启服务方便开发调试。

Uses

  1. <?php
  2. use Leevel\Option\Option;
  3. use Leevel\Protocol\IServer;

测试代码热重启

  1. public function testHotOverload(): void
  2. {
  3. $option = new Option([
  4. 'protocol' => [
  5. 'hotoverload_delay_count' => 1,
  6. 'hotoverload_time_interval' => 50,
  7. 'hotoverload_watch' => [
  8. __DIR__,
  9. __DIR__.'/Fixtures/HotOverloadDemo.php',
  10. ],
  11. ],
  12. ]);
  13. $hotOverload = new HotOverloadDemo($option, $this);
  14. /** @var \Leevel\Protocol\IServer $server */
  15. $server = $this->createMock(IServer::class);
  16. $hotOverload->handle($server);
  17. $this->assertSame(1, 1);
  18. }