当PHP内置服务器崩溃时,该端口仍在使用中

当PHP内置服务器崩溃时,该端口仍在使用中

问题描述:

I'm using PHP built in server like so:

$ composer serve
> php -S localhost:8000 -t public/

But it timed out..?

[Symfony\Component\Process\Exception\ProcessTimedOutException]                     
  The process "php -S localhost:8080 -t public/" exceeded the timeout of 300 seconds.

So, I tried to start it up again:

$ composer serve
> php -S localhost:8000 -t public/
[Thu May 26 21:31:51 2016] Failed to listen on localhost:8000 (reason: Address already in use)
Script php -S localhost:8000 -t public/ handling the serve event returned with error code 1

Why is the same port that the server was running on prior to timing out still in use? Can I stop all instances of PHP built in server?

If it matters, below is my composer.json file:

{
    .
    .
    .
    "scripts": {
        "serve": "php -S localhost:8000 -t public/"
    }
}

我正在使用PHP内置服务器,如下所示: p>

  $ composer serve 
>  php -S localhost:8000 -t public / 
  code>  pre> 
 
 

但它超时..? p>

  [Symfony  \ Component \ Process \ Exception \ ProcessTimedOutException] 
进程“php -S localhost:8080 -t public /”超过了300秒的超时时间。
  code>  pre> 
 
 

所以 ,我试着重新启动它: p>

  $ composer serve 
>  php -S localhost:8000 -t public / 
 [Thu May 26 21:31:51 2016]无法收听localhost:8000(原因:地址已在使用中)
Script php -S localhost:8000 -t public / 处理返回的服务事件,错误代码为1 
  code>  pre> 
 
 

为什么在超时之前服务器运行的端口仍在使用? 我可以停止服务器内置的所有PHP实例吗? p>

如果重要,下面是我的composer.json文件: p>

  {\  n。
。
。
“脚本”:{
“”“:”php -S localhost:8000 -t public /“
} 
} 
  code>  pre> \  n  div>

The problem is that composer has a default timeout after 300 seconds.

When executing the command you can use --timeout=0, this disables the timeout. In your example the command would look like composer run-script server --timeout=0

you can set the process timeout in your composer.json file like this :

  {
    ...
    "scripts": {
      "start": "php -S 127.0.0.1:80 .router.php -t public"
    },
    "config": {
      "process-timeout": 0
    }
  }

and start the web server like this :

$ composer start