server-man.php 746 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. require_once __DIR__ . '/vendor/autoload.php';
  3. use Adapterman\Adapterman;
  4. use Workerman\Worker;
  5. use Workerman\Timer;
  6. Adapterman::init();
  7. $http_worker = new Worker('http://0.0.0.0:8080');
  8. $http_worker->count = (int) shell_exec('nproc') * 4;
  9. $http_worker->reusePort = true;
  10. $http_worker->name = 'AdapterMan-Laravel';
  11. $http_worker->onWorkerStart = static function () {
  12. Header::$date = gmdate(DATE_RFC7231);
  13. Timer::add(1, function() {
  14. Header::$date = gmdate(DATE_RFC7231);
  15. });
  16. //init();
  17. require __DIR__.'/start.php';
  18. };
  19. $http_worker->onMessage = static function ($connection) {
  20. $connection->send(run());
  21. };
  22. Worker::runAll();
  23. class Header {
  24. public static $date;
  25. }