stanley-king 2 years ago
parent
commit
f79f0d7638

+ 3 - 3
docker/compose/homecuda/cli/docker-compose.yml

@@ -6,7 +6,7 @@ services:
     volumes:
       - /mnt/xyzshop:/var/www/html
       - /mnt/xyzshop/docker/compose/homecuda/conf/etc/localtime:/etc/localtime:ro
-      - /mnt/xyzshop/docker/compose/homecuda/conf/php/php.ini:/usr/local/etc/php/php.ini
+      - /mnt/xyzshop/docker/compose/homecuda/conf/php/php-debug.ini:/usr/local/etc/php/php.ini
       - /mnt/upload:/var/www/html/data/upload
       - /mnt/shoplog:/var/www/html/data/log
     container_name: "panda-php"
@@ -20,7 +20,7 @@ services:
     volumes:
       - ../../../../:/var/www/html
       - ../conf/etc/localtime:/etc/localtime:ro
-      - ../conf/php/php-swoole.ini:/usr/local/etc/php/php.ini
+      - ../conf/php/php-swoole-debug.ini:/usr/local/etc/php/php.ini
       - /mnt/upload:/var/www/html/data/upload
       - /mnt/shoplog:/var/www/html/data/log
       - ../conf/php/vender-init:/usr/local/bin/vender-init
@@ -31,7 +31,7 @@ services:
     volumes:
       - ../../../../:/var/www/html
       - ../conf/etc/localtime:/etc/localtime:ro
-      - ../conf/php/php.ini:/usr/local/etc/php/php.ini
+      - ../conf/php/php-debug.ini:/usr/local/etc/php/php.ini
       - /mnt/upload:/var/www/html/data/upload
 
       - /mnt/shoplog:/var/www/html/data/log

File diff suppressed because it is too large
+ 1952 - 0
docker/compose/homecuda/conf/php/php-debug.ini


File diff suppressed because it is too large
+ 1954 - 0
docker/compose/homecuda/conf/php/php-swoole-debug.ini


+ 1 - 11
docker/compose/homecuda/conf/php/php.ini

@@ -1939,14 +1939,4 @@ ldap.max_links = -1
 ; tab-width: 4
 ; End:
 
-output_buffering = On
-
-[xdebug]
-xdebug.default_enable=1
-xdebug.remote_enable=1
-xdebug.remote_handler=dbgp
-xdebug.remote_host=192.168.3.220
-xdebug.remote_port=9300
-xdebug.remote_mode=req
-xdebug.remote_autostart=1
-xdebug.idekey=PHPSTORM
+output_buffering = On

+ 1 - 12
docker/compose/homecuda/stat/docker-compose.yml

@@ -103,15 +103,4 @@ services:
       - /mnt/shoplog:/var/www/html/data/log
       - /mnt/stdata:/var/www/html/data/stdata
     container_name: "panda-mcounts"
-    command: ['python','mcounts.py','-h', '192.168.3.104', '-p', '6379']
-
-  qreader:
-    image: pycpu:3.7.10
-    volumes:
-      - ../../../../:/var/www/html
-      - ../conf/etc/localtime:/etc/localtime:ro
-      - /mnt/upload:/var/www/html/data/upload
-      - /mnt/shoplog:/var/www/html/data/log
-      - /mnt/stdata:/var/www/html/data/stdata
-    container_name: "panda-qreader"
-    command: ['mpiexec', '-n','4','python','qreader.py','-h', '192.168.3.104', '-p', '6379']
+    command: ['python','mcounts.py','-h', '192.168.3.104', '-p', '6379']

+ 14 - 0
docker/compose/homecuda/statsec/docker-compose.yml

@@ -0,0 +1,14 @@
+version: "3.7"
+
+services:
+  qreader:
+    image: pycpu:3.7.10
+    volumes:
+      - ../../../../:/var/www/html
+      - ../conf/etc/localtime:/etc/localtime:ro
+      - /mnt/upload:/var/www/html/data/upload
+      - /mnt/shoplog:/var/www/html/data/log
+      - /mnt/stdata:/var/www/html/data/stdata
+    container_name: "panda-qreader"
+#    command: [ 'mpiexec', '-n','4','python','qreader.py','-h', '192.168.3.104', '-p', '6379' ]
+    command: [ 'python','qreader.py','-h', '192.168.3.104', '-p', '6379' ]

+ 3 - 1
helper/refill/RefillBase.php

@@ -145,6 +145,7 @@ class RefillBase
                 $mod_refill->edit($order_id, ['is_retrying' => 1,'notify_time' => time()]);
                 $tran->commit();
 
+
                 util::incr_notify($chname, $card_type, $spec, $quality, false);
                 util::incr_amount_lock($mchid,$card_type,$spec);
 
@@ -156,6 +157,7 @@ class RefillBase
                     }
                 }
                 util::incr_user_fail($mchid,$card_type, $spec,$quality);
+                util::monitor_callback($mchid, $spec, $card_type, $refill_info['mch_amount'], 0, false);
             }
             else {
                 $logic_vr_order->changeOrderStateCancel($order_info, '', "{$chname}接口回调通知失败,不可重试.",true,true);
@@ -164,9 +166,9 @@ class RefillBase
                 util::incr_notify($chname, $card_type, $spec, $quality, false);
                 util::incr_amount_lock($mchid,$card_type,$spec);
                 util::incr_user_fail($mchid,$card_type, $spec,$quality);
+                util::monitor_callback($mchid, $spec, $card_type, $refill_info['mch_amount'], 0, false);
             }
 
-            util::monitor_callback($mchid, $spec, $card_type, $refill_info['mch_amount'], 0, false);
             $mod_refill->edit($order_id, ['notify_time' => time(), 'is_retrying' => 0,'notify_state' => 1]);
             util::pop_queue_order($mchid,$mch_order);
             QueueClient::push("NotifyMerchantComplete", ['order_id' => $order_id,'manual' => false]);

+ 4 - 3
plot/qreader.py

@@ -1,10 +1,10 @@
-from pandashop.plot.refill import queueListener
+from refill import queueListener
 import signal as sig
 import sys,getopt
 import logging
 
 logging.basicConfig(filename='/var/www/html/data/log/qreader.log', level=logging.DEBUG)
-log = logging.getLogger('reader')
+log = logging.getLogger('starter')
 
 def handle_sigterm(*args):
     queueListener.stop()
@@ -14,8 +14,9 @@ if __name__ == '__main__':
     try:
         opts, args = getopt.getopt(sys.argv[1:],"h:p:",["host=",'port='])
     except Exception as ex:
-        print(ex)
+        log.error(ex)
         sys.exit(2)
+
     rhost = ''
     rport = 6379
     for o, val in opts:

+ 24 - 0
plot/refill/ChannelReader.py

@@ -0,0 +1,24 @@
+# from . import DataHandler #此时是导入文件
+from .DataStream import DataReadStream, day_stamp,open_hdf5
+from .DataStream import EChPosmap as pos_map
+import numpy as np
+
+__all__ = ['MerchantReader']
+
+import logging
+log = logging.getLogger('reader')
+
+class ChannelReader(DataReadStream):
+    def __init__(self):
+        file = '/var/www/html/data/stdata/merchant.hdf5'
+        hfive = open_hdf5(file,False)
+        super(ChannelReader,self).__init__(hfive)
+
+    def __del__(self):
+        self.close()
+        super(ChannelReader, self).__del__()
+        pass
+
+    def read(self, path):
+        pass
+    pass

+ 1 - 0
plot/refill/ChannelWriter.py

@@ -58,6 +58,7 @@ class ChannelWriter(DataWriteStream):
         today = day_stamp(time)
         path = f'/{self._version}/{today}/{chname}/{card_type}/{spec}'
 
+        log.debug("%s,%s",'ChannelWriter',path)
         hfive = self.file
         if path not in hfive:
             dim = pos_map.dim()

+ 44 - 13
plot/refill/DataStream.py

@@ -1,11 +1,13 @@
 from abc import ABCMeta, abstractmethod, ABC
 from datetime import timedelta
-from mpi4py import MPI
+# from mpi4py import MPI
 import h5py
 from enum import IntEnum
 
 __all__ = ['DataWriteStream', 'DataReadStream', 'day_stamp', 'EMchPosmap', 'EChPosmap', 'ENetPosmap', 'open_hdf5']
 
+import logging
+log = logging.getLogger('stream')
 
 def day_stamp(stamp):
     import time as stime
@@ -19,9 +21,10 @@ def day_stamp(stamp):
 
 def open_hdf5(file, is_wirte):
     if is_wirte:
-        return h5py.File(file, 'a', driver='mpio', comm=MPI.COMM_WORLD)
+        # return h5py.File(file, 'a', driver='mpio', comm=MPI.COMM_WORLD)
+        return h5py.File(file, 'a')
     else:
-        return h5py.File(file, 'r', driver='mpio', comm=MPI.COMM_WORLD)
+        return h5py.File(file, 'r')
 
 
 class DataWriteStream(metaclass=ABCMeta):
@@ -47,11 +50,14 @@ class DataWriteStream(metaclass=ABCMeta):
     def close(self):
         if self._hfive is not None:
             self._hfive.close()
-pass
+            self._hfive = None
+
+    pass
 
 
 class DataReadStream(metaclass=ABCMeta):
     _version = 20200618
+
     def __init__(self, hfive):
         self._hfive = hfive
 
@@ -72,31 +78,52 @@ class DataReadStream(metaclass=ABCMeta):
     def close(self):
         if self._hfive is not None:
             self._hfive.close()
+            self._hfive = None
 
-    def _days(self, root):
+    def _sub_dirs(self, root):
         result = []
         try:
             for name, sub in root.items():
                 if isinstance(sub, h5py.Group):
                     result.append(name)
         except Exception as ex:
-            print(ex)
+            log.error(ex)
         finally:
             return result
 
+    def dir(self, group):
+        result = []
+        for name, sub in group.items():
+            if isinstance(sub, h5py.Group):
+                result.extend(self.dir(sub))
+            else:
+                result.append(sub.name)
+        return result
+
     def _root_path(self):
-        return f'/{self._version}'
+        return f'/{self._version}/'
+
+    def dirs(self):
+        try:
+            root_ptah = self._root_path()
+            root = self.file.require_group(root_ptah)
+            days = self.dir(root)
+            return days
+        except Exception as ex:
+            log.error(ex)
+            return []
 
     def days(self):
         try:
             root_ptah = self._root_path()
             root = self.file.require_group(root_ptah)
-            days = self._days(root)
+            days = self._sub_dirs(root)
             return days
         except Exception as ex:
-            print(ex)
+            log.error(ex)
             return []
-pass
+
+    pass
 
 
 class EMchPosmap(IntEnum):
@@ -111,7 +138,8 @@ class EMchPosmap(IntEnum):
     @staticmethod
     def dim():
         return 7
-pass
+
+    pass
 
 
 class EChPosmap(IntEnum):
@@ -127,7 +155,9 @@ class EChPosmap(IntEnum):
     @staticmethod
     def dim():
         return 8
-pass
+
+    pass
+
 
 class ENetPosmap(IntEnum):
     succ_count = 0
@@ -136,4 +166,5 @@ class ENetPosmap(IntEnum):
     @staticmethod
     def dim():
         return 2
-pass
+
+    pass

+ 7 - 6
plot/refill/MerchantReader.py

@@ -6,18 +6,19 @@ import numpy as np
 __all__ = ['MerchantReader']
 
 import logging
-log = logging.getLogger('writer')
+log = logging.getLogger('reader')
 
 class MerchantReader(DataReadStream):
     def __init__(self):
         file = '/var/www/html/data/stdata/merchant.hdf5'
-        hfive = open_hdf5(file,True)
+        hfive = open_hdf5(file,False)
         super(MerchantReader,self).__init__(hfive)
 
-    # def __del__(self):
-    #     self.close()
-    #     pass
+    def __del__(self):
+        self.close()
+        super(MerchantReader, self).__del__()
+        pass
 
     def read(self, path):
         pass
-pass
+    pass

+ 1 - 0
plot/refill/MerchantWriter.py

@@ -57,6 +57,7 @@ class MerchantWriter(DataWriteStream):
         today = day_stamp(time)
         path = f'/{self._version}/{today}/{mchid}/{card_type}/{spec}'
 
+        log.debug("%s,%s",'MerchantWriter',path)
         hfive = self.file
         if path not in hfive:
             dim = pos_map.dim()

+ 21 - 0
plot/refill/NetchkReader.py

@@ -0,0 +1,21 @@
+from .DataStream import DataReadStream,open_hdf5
+import numpy as np
+
+__all__ = ['NetchkReader']
+
+import logging
+log = logging.getLogger('reader')
+
+class NetchkReader(DataReadStream):
+    def __init__(self):
+        file = '/var/www/html/data/stdata/netchk.hdf5'
+        hfive = open_hdf5(file,False)
+        super(NetchkReader,self).__init__(hfive)
+
+    def __del__(self):
+        self.close()
+        super(NetchkReader, self).__del__()
+
+    def read(self, path):
+        pass
+    pass

+ 4 - 0
plot/refill/NetchkWriter.py

@@ -6,8 +6,10 @@ import numpy as np
 __all__ = ['NetchkWriter']
 
 import logging
+
 log = logging.getLogger('writer')
 
+
 class NetchkWriter(DataWriteStream):
     def write(self, method, params):
         if method == 'net_succ':
@@ -41,6 +43,8 @@ class NetchkWriter(DataWriteStream):
         today = day_stamp(time)
         path = f'/{self._version}/{today}/{chname}'
 
+        log.debug("%s,%s", 'NetchkWriter', path)
+
         hfive = self.file
         if path not in hfive:
             dim = pos_map.dim()

+ 0 - 1
plot/refill/QueueListener.py

@@ -1,5 +1,4 @@
 import json
-import os
 import time as stime
 import redis
 

+ 3 - 1
plot/refill/__init__.py

@@ -6,8 +6,10 @@ from .ChannelWriter import ChannelWriter
 from .NetchkWriter import NetchkWriter
 
 from .MerchantReader import MerchantReader
+from .NetchkReader import NetchkReader
+from .ChannelReader import ChannelReader
 
 __all__ = ['DataWriteStream', 'DataReadStream',
            'MerchantWriter', 'ChannelWriter','NetchkWriter',
-           'MerchantReader',
+           'MerchantReader','NetchkReader','ChannelReader',
            'queueListener','open_hdf5']

+ 19 - 5
plot/testPlot.py

@@ -5,15 +5,19 @@ logging.basicConfig(filename='/var/www/html/data/log/qreader.log', level=logging
 log = logging.getLogger('reader')
 
 class MyTestCase(unittest.TestCase):
-    # __redis_host = '192.168.3.104'
-    __redis_host = '192.168.3.46'
+    __redis_host = '192.168.3.104'
+    # __redis_host = '192.168.3.46'
     def test_something(self):
         self.assertEqual(True, False)  # add assertion here
 
     def test_listener(self):
-        from refill import queueListener
-        queueListener.set_redis(self.__redis_host,'6379')
-        queueListener.prepare_data()
+        try:
+            from refill import queueListener
+            queueListener.set_redis(self.__redis_host,'6379')
+            queueListener.prepare_data()
+        except Exception as ex:
+            log.error(ex)
+        pass
 
     def testDays(self):
         from refill import MerchantReader
@@ -25,6 +29,16 @@ class MyTestCase(unittest.TestCase):
             log.error(ex)
         pass
 
+    def testDirs(self):
+        from refill import NetchkReader
+
+        try:
+            reader = NetchkReader()
+            paths = reader.dirs()
+        except Exception as ex:
+            log.error(ex)
+        pass
+
     def test_jsonLoads(self):
         import json
         try: