public function post_uncheck_task() { $data = Input::all(); Tasks::where(array('id' => $data['uncheck_task'], 'user_id' => Auth::id()))->update(array('status' => 0, 'updated_at' => new DateTime())); $updated_task = Tasks::where(array('id' => $data['uncheck_task'], 'user_id' => Auth::id()))->first(); return array('task_name' => $updated_task->task_name); }
/** * Execute the console command. * * @return mixed */ public function fire() { //启动之前先检查进程是否还活着,如果还活着咱就退 windows 下 tasklist /fi "PID eq xxxx" if (file_exists($this->filelock) && function_exists('posix_kill') && posix_kill(intval(file_get_contents($this->filelock)), 0)) { die("pid exists,exit"); } file_put_contents($this->filelock, getmypid()); Tasks::where("status", "execute")->update(array("status" => "created")); while (true) { //获取任务,执行任务 $tasks = Tasks::where('status', 'created')->lists('id'); foreach ($tasks as $_id) { //TaskHelper Task::run($_id); } sleep(1); } }