Ejemplo n.º 1
0
 public static function socketPath(string $config)
 {
     // that base64_encode instead of the standard hex representation of sha1 is necessary to avoid overly long paths for unix domain sockets
     return sys_get_temp_dir() . "/aerys_" . strtr(base64_encode(sha1(Bootstrapper::selectConfigFile($config), true)), "+/", "-_") . ".tmp";
 }
Ejemplo n.º 2
0
 private function bindCommandServer(string $config)
 {
     $path = CommandClient::socketPath(Bootstrapper::selectConfigFile($config));
     if ((yield \Amp\file\exists($path))) {
         if (is_resource(@stream_socket_client((yield \Amp\file\get($path))))) {
             throw new \RuntimeException("Aerys is already running, can't start it again");
         }
     }
     if (!($commandServer = @stream_socket_server("tcp://127.0.0.1:*", $errno, $errstr))) {
         throw new \RuntimeException(sprintf("Failed binding socket server on tcp://127.0.0.1:*: [%d] %s", $errno, $errstr));
     }
     stream_set_blocking($commandServer, false);
     \Amp\onReadable($commandServer, function (...$args) {
         $this->acceptCommand(...$args);
     });
     register_shutdown_function(function () use($path) {
         @\unlink($path);
     });
     (yield \Amp\file\put($path, stream_socket_get_name($commandServer, $wantPeer = false)));
 }
Ejemplo n.º 3
0
 public static function socketPath(string $config)
 {
     return sys_get_temp_dir() . "/aerys_" . str_replace(["/", ":"], "_", Bootstrapper::selectConfigFile($config)) . ".tmp";
 }
Ejemplo n.º 4
0
 public static function socketPath(string $config)
 {
     return sys_get_temp_dir() . "/aerys_" . sha1(Bootstrapper::selectConfigFile($config)) . ".tmp";
 }