Parcourir la source

applications/Demo 兼容windows系统

walkor il y a 11 ans
Parent
commit
78f2131691

+ 8 - 1
applications/Demo/Bootstrap/Gateway.php

@@ -154,7 +154,14 @@ class Gateway extends Man\Core\SocketWorker
         // 创建内部通信套接字,用于与BusinessWorker通讯
         $start_port = Man\Core\Lib\Config::get($this->workerName.'.lan_port_start');
         // 计算本进程监听的ip端口
-        $this->lanPort = $start_port - posix_getppid() + posix_getpid();
+        if(function_exists('posix_getppid'))
+        {
+            $this->lanPort = $start_port - posix_getppid() + posix_getpid();
+        }
+        else 
+        {
+            $this->lanPort = $start_port + \Thread::getCurrentThreadId()%100;
+        }
         // 如果端口不在合法范围
         if($this->lanPort<0 || $this->lanPort >=65535)
         {

+ 1 - 1
applications/Demo/Config/Store.php

@@ -27,5 +27,5 @@ class Store
      * 注意:如果修改了storePath,要将storePath加入到conf/conf.d/FileMonitor.conf的忽略目录中 
      * 例如 $storePath = '/home/data/',则需要在conf/conf.d/FileMonitor.conf加一行 exclude_path[]=/home/data/
      */
-    public static $storePath = '/tmp/workerman-Demo/';
+    public static $storePath = './logs/workerman-demo/';
 }

+ 2 - 2
applications/Demo/Lib/StoreDriver/File.php

@@ -45,10 +45,10 @@ class File
         {
             touch($this->dataFile);
         }
-        $this->dataFileHandle = fopen($this->dataFile, 'r+');
+        $this->dataFileHandle = fopen(__FILE__, 'r');
         if(!$this->dataFileHandle)
         {
-            throw new \Exception("can not fopen($this->dataFile, 'r+')");
+            throw new \Exception("can not fopen($this->dataFile, 'r')");
         }
     }