server.php 740 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. require_once __DIR__ . '/vendor/autoload.php';
  3. use Adapterman\Adapterman;
  4. use Workerman\Worker;
  5. use Workerman\Lib\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->name = 'AdapterMan-Symfony';
  10. $http_worker->onWorkerStart = function () {
  11. Header::$date = gmdate('D, d M Y H:i:s').' GMT';
  12. Timer::add(1, function() {
  13. Header::$date = gmdate('D, d M Y H:i:s').' GMT';
  14. });
  15. //init();
  16. require __DIR__.'/start.php';
  17. };
  18. $http_worker->onMessage = static function ($connection, $request) {
  19. $connection->send(run());
  20. };
  21. Worker::runAll();
  22. class Header {
  23. public static $date;
  24. }