function at(callable $m, $ts = 'now', $args = []) { $time = 'now' == $ts ? time() : $ts; $c = lib('utils')->stringClosure($m); $hash = sha1($c . serialize($args)); $row = Model::Bus()->firstOrCreate(['hash' => $hash])->setArgs(serialize($args))->setMethod($c)->setStatus(2)->setTime($time)->save(); if ('now' == $ts) { $file = Config::get('app.module.dir') . DS . 'background.php'; if (file_exists($file)) { $cmd = 'php ' . $file; lib('utils')->backgroundTask($cmd); } } }