当前位置: 首页>>代码示例>>PHP>>正文


PHP Server::forceShutdown方法代码示例

本文整理汇总了PHP中pocketmine\Server::forceShutdown方法的典型用法代码示例。如果您正苦于以下问题:PHP Server::forceShutdown方法的具体用法?PHP Server::forceShutdown怎么用?PHP Server::forceShutdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pocketmine\Server的用法示例。


在下文中一共展示了Server::forceShutdown方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: dumpServerMemory

 public function dumpServerMemory($outputFolder, $maxNesting, $maxStringSize)
 {
     gc_disable();
     if (!file_exists($outputFolder)) {
         mkdir($outputFolder, 0777, true);
     }
     $this->server->getLogger()->notice("[Dump] After the memory dump is done, the server might crash");
     $obData = fopen($outputFolder . "/objects.js", "wb+");
     $staticProperties = [];
     $data = [];
     $objects = [];
     $refCounts = [];
     $this->continueDump($this->server, $data, $objects, $refCounts, 0, $maxNesting, $maxStringSize);
     do {
         $continue = false;
         foreach ($objects as $hash => $object) {
             if (!is_object($object)) {
                 continue;
             }
             $continue = true;
             $className = get_class($object);
             $objects[$hash] = true;
             $reflection = new \ReflectionObject($object);
             $info = ["information" => "{$hash}@{$className}", "properties" => []];
             if ($reflection->getParentClass()) {
                 $info["parent"] = $reflection->getParentClass()->getName();
             }
             if (count($reflection->getInterfaceNames()) > 0) {
                 $info["implements"] = implode(", ", $reflection->getInterfaceNames());
             }
             foreach ($reflection->getProperties() as $property) {
                 if ($property->isStatic()) {
                     continue;
                 }
                 if (!$property->isPublic()) {
                     $property->setAccessible(true);
                 }
                 $this->continueDump($property->getValue($object), $info["properties"][$property->getName()], $objects, $refCounts, 0, $maxNesting, $maxStringSize);
             }
             fwrite($obData, "{$hash}@{$className}: " . json_encode($info, JSON_UNESCAPED_SLASHES) . "\n");
             if (!isset($objects["staticProperties"][$className])) {
                 $staticProperties[$className] = [];
                 foreach ($reflection->getProperties() as $property) {
                     if (!$property->isStatic() or $property->getDeclaringClass()->getName() !== $className) {
                         continue;
                     }
                     if (!$property->isPublic()) {
                         $property->setAccessible(true);
                     }
                     $this->continueDump($property->getValue($object), $staticProperties[$className][$property->getName()], $objects, $refCounts, 0, $maxNesting, $maxStringSize);
                 }
             }
         }
         echo "[Dump] Wrote " . count($objects) . " objects\n";
     } while ($continue);
     file_put_contents($outputFolder . "/staticProperties.js", json_encode($staticProperties, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
     file_put_contents($outputFolder . "/serverEntry.js", json_encode($data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
     file_put_contents($outputFolder . "/referenceCounts.js", json_encode($refCounts, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT));
     echo "[Dump] Finished!\n";
     gc_enable();
     $this->server->forceShutdown();
 }
开发者ID:ianju,项目名称:PocketMine-MP,代码行数:62,代码来源:MemoryManager.php


注:本文中的pocketmine\Server::forceShutdown方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。