Parcourir la source

add merchant task

stanley-king il y a 2 ans
Parent
commit
1bd43024d3

+ 18 - 6
crontab/control/minutes.php

@@ -409,19 +409,15 @@ class minutesControl extends BaseCronControl
         }
     }
 
-    //任务队列处理
-    public function taskOp()
+    private function exec_task($merchant)
     {
-        Log::short_name('task');
-        Log::record('start task',Log::DEBUG);
-
         $task_manager = new task\manager();
         $task_id = 0;
         while (true)
         {
             try
             {
-                $task = $task_manager->pop_task($task_id);
+                $task = $task_manager->pop_task($task_id,$merchant);
                 if (!empty($task)) {
                     $task_manager->handle($task);
                     $task_id = $task['task_id'];
@@ -435,6 +431,22 @@ class minutesControl extends BaseCronControl
         }
     }
 
+    //任务队列处理
+    public function admin_taskOp()
+    {
+        Log::short_name('task');
+        Log::record('start task',Log::DEBUG);
+        $this->exec_task(false);
+    }
+
+    //任务队列处理
+    public function merchant_taskOp()
+    {
+        Log::short_name('merchant_task');
+        Log::record('start task',Log::DEBUG);
+        $this->exec_task(true);
+    }
+
     //更新统计业务数据
     public function stat_utilOp()
     {

+ 1 - 1
docker/compose/xyz/admin/docker-compose.yml

@@ -36,7 +36,7 @@ services:
     deploy:
       resources:
         limits:
-          cpus: '8'
+          cpus: '4'
 
   websrv:
     image: php-fpm:alpine

+ 63 - 10
docker/compose/xyz/slave-crond/docker-compose.yml

@@ -27,11 +27,7 @@ services:
       - /nfs/upload:/var/www/html/data/upload
       - /mnt/shoplog:/var/www/html/data/log
     container_name: "panda-taska"
-    command: [php,"/var/www/html/crontab/index.php",'minutes','task']
-    deploy:
-      resources:
-        limits:
-          cpus: '8'
+    command: [php,"/var/www/html/crontab/index.php",'minutes','admin_task']
 
   taskb:
     image: php-zts-debug:7.3.18
@@ -43,11 +39,68 @@ services:
       - /nfs/upload:/var/www/html/data/upload
       - /mnt/shoplog:/var/www/html/data/log
     container_name: "panda-taskb"
-    command: [php,"/var/www/html/crontab/index.php",'minutes','task']
-    deploy:
-      resources:
-        limits:
-          cpus: '8'
+    command: [php,"/var/www/html/crontab/index.php",'minutes','admin_task']
+
+  taskc:
+    image: php-zts-debug:7.3.18
+    volumes:
+      - ../../../../:/var/www/html
+      - ../conf/etc/localtime:/etc/localtime:ro
+      - ../conf/php/php.ini:/usr/local/etc/php/php.ini
+      - ../conf/crontab/slave_root:/var/spool/cron/crontabs/root
+      - /nfs/upload:/var/www/html/data/upload
+      - /mnt/shoplog:/var/www/html/data/log
+    container_name: "panda-taskc"
+    command: [php,"/var/www/html/crontab/index.php",'minutes','admin_task']
+
+  mtaska:
+    image: php-zts:7.3.18
+    volumes:
+      - ../../../../:/var/www/html
+      - ../conf/etc/localtime:/etc/localtime:ro
+      - ../conf/php/php.ini:/usr/local/etc/php/php.ini
+      - ../conf/crontab/slave_root:/var/spool/cron/crontabs/root
+      - /nfs/upload:/var/www/html/data/upload
+      - /mnt/shoplog:/var/www/html/data/log
+    container_name: "panda-mtaska"
+    command: [php,"/var/www/html/crontab/index.php",'minutes','merchant_task']
+
+  mtaskb:
+    image: php-zts:7.3.18
+    volumes:
+      - ../../../../:/var/www/html
+      - ../conf/etc/localtime:/etc/localtime:ro
+      - ../conf/php/php.ini:/usr/local/etc/php/php.ini
+      - ../conf/crontab/slave_root:/var/spool/cron/crontabs/root
+      - /nfs/upload:/var/www/html/data/upload
+      - /mnt/shoplog:/var/www/html/data/log
+    container_name: "panda-mtaskb"
+    command: [php,"/var/www/html/crontab/index.php",'minutes','merchant_task']
+
+  mtaskc:
+    image: php-zts:7.3.18
+    volumes:
+      - ../../../../:/var/www/html
+      - ../conf/etc/localtime:/etc/localtime:ro
+      - ../conf/php/php.ini:/usr/local/etc/php/php.ini
+      - ../conf/crontab/slave_root:/var/spool/cron/crontabs/root
+      - /nfs/upload:/var/www/html/data/upload
+      - /mnt/shoplog:/var/www/html/data/log
+    container_name: "panda-mtaskc"
+    command: [php,"/var/www/html/crontab/index.php",'minutes','merchant_task']
+
+  mtaskd:
+    image: php-zts:7.3.18
+    volumes:
+      - ../../../../:/var/www/html
+      - ../conf/etc/localtime:/etc/localtime:ro
+      - ../conf/php/php.ini:/usr/local/etc/php/php.ini
+      - ../conf/crontab/slave_root:/var/spool/cron/crontabs/root
+      - /nfs/upload:/var/www/html/data/upload
+      - /mnt/shoplog:/var/www/html/data/log
+    container_name: "panda-mtaskd"
+    command: [php,"/var/www/html/crontab/index.php",'minutes','merchant_task']
+
 
   statutil:
     image: php-zts-debug:7.3.18

+ 1 - 1
docker/compose/yl/yladmin/docker-compose.yml

@@ -37,7 +37,7 @@ services:
     deploy:
       resources:
         limits:
-          cpus: '8'
+          cpus: '4'
 
   web:
     image: php-fpm:alpine

+ 3 - 3
docker/compose/yl/ylslave-crond/docker-compose.yml

@@ -27,7 +27,7 @@ services:
       - /nfs/ylupload:/var/www/html/data/upload
       - /mnt/yllog:/var/www/html/data/log
     container_name: "yl-taska"
-    command: [php,"/var/www/html/crontab/index.php",'minutes','task']
+    command: [php,"/var/www/html/crontab/index.php",'minutes','admin_task']
     deploy:
       resources:
         limits:
@@ -43,7 +43,7 @@ services:
       - /nfs/ylupload:/var/www/html/data/upload
       - /mnt/yllog:/var/www/html/data/log
     container_name: "yl-taskb"
-    command: [php,"/var/www/html/crontab/index.php",'minutes','task']
+    command: [php,"/var/www/html/crontab/index.php",'minutes','admin_task']
     deploy:
       resources:
         limits:
@@ -59,7 +59,7 @@ services:
       - /nfs/ylupload:/var/www/html/data/upload
       - /mnt/yllog:/var/www/html/data/log
     container_name: "yl-taskc"
-    command: [php,"/var/www/html/crontab/index.php",'minutes','task']
+    command: [php,"/var/www/html/crontab/index.php",'minutes','admin_task']
     deploy:
       resources:
         limits:

+ 13 - 5
helper/task/manager.php

@@ -55,15 +55,23 @@ class manager
     }
 
     //弹出一个任务,并且将任务设为进行中
-    public function pop_task($task_id)
+    public function pop_task($task_id,$merchant = false)
     {
         $mod_task = Model('task');
         $trans = new trans_wapper($mod_task,'pop_task');
 
-        try {
-            $item = $mod_task->field('*')
-                             ->where(['task_id' => ['gt',$task_id],'state' => task_wrapper::Waiting])
-                             ->master(true)->lock(true)->find();
+        try
+        {
+            if($merchant)
+            {
+                $item = $mod_task->field('*')
+                    ->where(['task_id' => ['gt',$task_id],'state' => task_wrapper::Waiting,'mchid' => ['gt',0]])
+                    ->master(true)->lock(true)->find();
+            } else {
+                $item = $mod_task->field('*')
+                    ->where(['task_id' => ['gt',$task_id],'state' => task_wrapper::Waiting,'mchid' => 0])
+                    ->master(true)->lock(true)->find();
+            }
 
             if(!empty($item)) {
                 $mod_task->where(['task_id' => $item['task_id']])->update(['state' => task_wrapper::Processing,'act_time' => time()]);