app->session->get('user.username') === 'admin') { try { $this->message = $this->app->console->call('xtask:state')->fetch(); $this->command = ProcessService::instance($this->app)->think('xtask:start'); } catch (\Exception $exception) { $this->message = $exception->getMessage(); } } $this->title = '系统任务管理'; $this->iswin = PATH_SEPARATOR === ';'; $query = $this->_query($this->table)->dateBetween('create_at,start_at,end_at'); $query->like('title,preload')->equal('status')->order('id desc')->page(); } /** * 删除系统任务 * @auth true * @throws \think\db\exception\DbException */ public function remove() { $this->_delete($this->table); } /** * 重启系统任务 * @auth true * @throws \think\db\exception\DbException */ public function redo() { $this->_save($this->table, ['status' => '1']); } /** * 重启任务结果处理 * @param boolean $state */ protected function _redo_save_result($state) { if ($state) $this->success('重启任务成功!'); } /** * WIN创建监听进程 * @auth true */ public function start() { try { $this->success(nl2br($this->app->console->call('xtask:start')->fetch())); } catch (HttpResponseException $exception) { throw $exception; } catch (\Exception $e) { $this->error($e->getMessage()); } } /** * WIN停止监听进程 * @auth true */ public function stop() { try { $this->success(nl2br($this->app->console->call('xtask:stop')->fetch())); } catch (HttpResponseException $exception) { throw $exception; } catch (\Exception $e) { $this->error($e->getMessage()); } } }