Cml\Tools\Daemon\ProcessManage::rmTask PHP Method

rmTask() public static method

删除任务
public static rmTask ( string $task ) : void
$task string 任务的类名带命名空间
return void
    public static function rmTask($task)
    {
        self::initEvn();
        $task || self::message('task name is empty');
        $status = self::getStatus();
        if (!isset($status['task']) || count($status['task']) < 1) {
            self::message('task is empty');
            return;
        }
        $key = md5($task);
        if (isset($status['task'][$key])) {
            unset($status['task'][$key]);
        } else {
            self::message($task . 'task not found');
            return;
        }
        self::message("rm task [{$task}] success");
        file_put_contents(self::$status, '<?php return ' . var_export($status, true) . ';', LOCK_EX);
        self::message('task nums (' . count($status['task']) . ') list  [' . json_encode($status['task'], JSON_UNESCAPED_UNICODE) . ']');
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * 添加一个后台任务
  *
  * @param array $args 传递给命令的参数
  * @param array $options 传递给命令的选项
  *
  * @throws \InvalidArgumentException
  */
 public function execute(array $args, array $options = [])
 {
     if (!isset($args[0])) {
         throw new \InvalidArgumentException('arg action must be input');
     }
     $action = explode('::', $args[0]);
     if (!class_exists($action[0])) {
         throw new \InvalidArgumentException('action not not found!');
     }
     ProcessManage::rmTask($action);
 }