123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <?php
- namespace app\admin\controller;
- use think\admin\Controller;
- use think\admin\extend\ProcessExtend;
- use think\exception\HttpResponseException;
- class Queue extends Controller
- {
-
- protected $table = 'SystemQueue';
-
- public function index()
- {
- if ($this->app->session->get('user.username') === 'admin') {
- try {
- $this->command = ProcessExtend::think('xtask:start');
- $this->message = $this->app->console->call('xtask:state')->fetch();
- } 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();
- }
-
- public function redo()
- {
- $this->_save($this->table, ['status' => '1']);
- }
-
- 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());
- }
- }
-
- 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());
- }
- }
-
- public function remove()
- {
- $this->_delete($this->table);
- }
- }
|