Skip to content
master
Switch branches/tags
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 

php-server

通过 PHP 控制进程,实现一个简易的 Server,具体见 用 PHP 玩转进程之二 — 多进程 PHPServer

控制流程

控制流程

命令

该 PHPServer 仅实现了start|stop|reload|help命令。

$ php server.php --help
Usage: Commands [mode]

Commands:
start		Start worker.
stop		Stop worker.
reload		Reload codes.

Options:
-d		to start in DAEMON mode.

Use "--help" for more information about a command.

start

$ php server.php start -d
PHPServer start	  [OK]

$ pstree -p
init(1)-+-init(3)---bash(5)
        |-php(10525)-+-php(10526)
        |            |-php(10527)
        |            |-php(10528)
        |            |-php(10529)
        |            |-php(10530)
        |            |-php(10531)
        |            |-php(10532)
        |            |-php(10533)
        |            |-php(10534)
        |            `-php(10535)

stop

$ php server.php stop
PHPServer stopping ...
PHPServer stop success

reload

reload只会重载 worker 进程,也就是说reload时 master 进程 PID 并不会变化。

$ pstree -p
init(1)-+-init(3)---bash(5)
        |-php(10525)-+-php(10526)
        |            |-php(10527)
        |            |-php(10528)
        |            |-php(10529)
        |            |-php(10530)
        |            |-php(10531)
        |            |-php(10532)
        |            |-php(10533)
        |            |-php(10534)
        |            `-php(10535)

$ php server.php reload
PHPServer reloading ...

$ pstree -p
init(1)-+-init(3)---bash(5)
        |-php(10525)-+-php(10538)
        |            |-php(10539)
        |            |-php(10540)
        |            |-php(10541)
        |            |-php(10542)
        |            |-php(10543)
        |            |-php(10544)
        |            |-php(10545)
        |            |-php(10546)
        |            `-php(10547)

About

用PHP实现一个简易的Server

Topics

Resources

Releases

No releases published

Packages

No packages published

Languages