index.blade.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  1. @extends('layouts.base')
  2. <style>
  3. .panel{
  4. margin-bottom:10px!important;
  5. padding-left: 20px;
  6. border-radius: 10px;
  7. }
  8. .panel .active a {
  9. background-color: #29ba9c!important;
  10. border-radius: 18px!important;
  11. color:#fff;
  12. }
  13. .panel a{
  14. border:none!important;
  15. background-color:#fff!important;
  16. }
  17. .content{
  18. background: #eff3f6;
  19. padding: 10px!important;
  20. }
  21. .text {
  22. font-size: 14px;
  23. }
  24. .host {
  25. font-size: 20px;
  26. }
  27. .item {
  28. margin-bottom: 18px;
  29. }
  30. .process {
  31. margin-left: 20px;
  32. }
  33. .item>span{
  34. display: inline-block;
  35. }
  36. .clearfix:before,
  37. .clearfix:after {
  38. display: table;
  39. content: "";
  40. }
  41. .clearfix:after {
  42. clear: both
  43. }
  44. .box-card {
  45. width: 100%;
  46. margin-top:20px;
  47. float:left;
  48. }
  49. .box-log {
  50. width: 48%;
  51. margin-top:20px;
  52. float:right;
  53. }
  54. .system-situation .el-button .el-icon-s-opportunity {
  55. font-size: 30px;
  56. }
  57. .row-sty p{
  58. margin: 0;
  59. }
  60. </style>
  61. @section('content')
  62. <div class="w1200 m0a">
  63. <div class="rightlist">
  64. @include('layouts.newTabs')
  65. <div id="app">
  66. <el-card class="box-card">
  67. <div class="vue-head system-situation">
  68. <div class="vue-main-title">
  69. <div class="vue-main-title-left"></div>
  70. <div class="vue-main-title-content"><span
  71. style="width: 4px;height: 10px;background-color: #29ba9c;margin-right:15px;display:inline-block;">
  72. </span><b>系统运行情况</b></div>
  73. </div>
  74. <div class="system-situation_tips">
  75. 如果为红色图标,表示系统运营异常,10分钟左右刷新未恢复正常的,请第一时间联系客服处理!
  76. </div>
  77. <el-row style="margin-top: 25px" type="flex" justify="center" :gutter="20" align="center" class="row-sty">
  78. <el-col :span="5">
  79. <div class="" style="text-align: center;">
  80. <p v-for="(item,index) in queue_color" :key="index">
  81. <el-button v-if="queue_hearteat.daemon.queue_status == item.color" :type="item.value" :title="queue_hearteat.daemon.title" icon="el-icon-s-opportunity" circle></el-button>
  82. </p>
  83. <p style="margin-top:10px;"> 守护进程 <span v-if="queue_hearteat.daemon.queue_status != 'green'" style="color: red;">${queue_hearteat.daemon.msg}</span></p>
  84. </div>
  85. </el-col>
  86. <el-col :span="5">
  87. <div class="" style="text-align: center;">
  88. <p v-for="(item,index) in queue_color" :key="index">
  89. <el-button v-if="queue_hearteat.job.queue_status == item.color" :type="item.value" :title="item.label" icon="el-icon-s-opportunity" circle></el-button>
  90. </p>
  91. <p style="margin-top:10px;">队列 <span v-if="queue_hearteat.job.queue_status != 'green'" style="color: red">${queue_hearteat.job.msg}</span> <span v-if="queue_hearteat.job.is_repeat > 1" style="color: red">重复执行</span> </p>
  92. </div>
  93. </el-col>
  94. <el-col :span="5">
  95. <div class="" style="text-align: center;">
  96. <p v-for="(item,index) in queue_color" :key="index">
  97. <el-button v-if="queue_hearteat.cron.queue_status == item.color" :type="item.value" :title="item.label" icon="el-icon-s-opportunity" circle></el-button>
  98. </p>
  99. <p style="margin-top:10px;"> 定时任务 <span v-if="queue_hearteat.cron.queue_status != 'green'" style="color: red">${queue_hearteat.cron.msg}</span> <span v-if="queue_hearteat.cron.is_repeat > 1" style="color: red">重复执行</span></p>
  100. </div>
  101. </el-col>
  102. <el-col :span="5">
  103. <div style="text-align: center;">
  104. <p v-for="(item,index) in queue_color" :key="index">
  105. <el-button v-if="queue_hearteat.redis.queue_status == item.color" :type="item.value" :title="item.label" icon="el-icon-s-opportunity" circle></el-button>
  106. </p>
  107. <p style="margin-top:10px;"> Redis <span v-if="queue_hearteat.redis.queue_status != 'green'" style="color: red">${queue_hearteat.redis.msg}</span></p>
  108. </div>
  109. </el-col>
  110. </el-row>
  111. </div>
  112. </el-card>
  113. <el-card class="box-card">
  114. <div slot="header" class="clearfix">
  115. <span style="float: right;">
  116. <el-tag v-if="service_type!=2">
  117. <el-button size="small" v-if="stopAllState" disabled type="info"><i style="" class="el-icon-loading"></i>停止进程中...</el-button>
  118. <el-button size="small" v-else @click="stopAll" type="info">停止所有进程<i style="" class="el-icon-caret-right el-icon--right"></i></el-button>
  119. <el-button size="small" v-if="startAllState" disabled type="success"><i style="" class="el-icon-loading"></i>启动进程中...</el-button>
  120. <el-button size="small" v-else @click="startAll" type="success">启动所有进程<i style="" class="el-icon-caret-right el-icon--right"></i></el-button>
  121. </el-tag>
  122. <el-button size="small" v-if="restartState" disabled type="primary"><i style="" class="el-icon-loading"></i>重启中...</el-button>
  123. <el-button size="small" v-else @click="restart" type="primary">重启<i style="" class="el-icon-caret-right el-icon--right"></i></el-button>
  124. </span>
  125. </div>
  126. <div v-for="(process, hostname) in list" class="host item">
  127. <span style="width:35%" v-if="state">ip地址:${hostname}</span>
  128. <el-tag v-if="state[hostname].val.statecode == 1" type="success">运行中</el-tag>
  129. <el-tag v-else-if="state[hostname].val.statecode == 2"><i style="" class="el-icon-loading"></i>加载中...</el-tag>
  130. <el-tag v-else type="danger">未运行</el-tag>
  131. <div v-for="(supervisor,key) in process.val" class="text item process">
  132. <span style="width:35%">${ supervisor.name }</span>
  133. <span style="width:22%">
  134. <el-button round v-if="supervisor.statename == 'RUNNING'" type="text" size="small">已启动<i style="" class="el-icon-circle-check-outline el-icon--right"></i></el-button>
  135. <el-button round v-else type="danger" size="small">已停止<i style="" class="el-icon-circle-close-outline el-icon--right"></i></el-button>
  136. </span>
  137. <span style="width:42%; float:right;text-align:right;">
  138. <el-button @click="start(supervisor,hostname)" v-if="supervisor.statename != 'RUNNING'" type="success" size="small">启动<i style="" class="el-icon-caret-right el-icon--right"></i></el-button>
  139. <el-button @click="stop(supervisor,hostname)" v-if="service_type!=2 && supervisor.statename == 'RUNNING'" type="info" size="small">停止<i style="" class="el-icon-close el-icon--right"></i></el-button>
  140. <el-button v-if="!supervisor.cstate" @click="showlog(supervisor,key,hostname)" type="info" size="small">日志<i style="" class="el-icon-search el-icon--right"></i></el-button>
  141. <el-button v-else disabled type="primary" size="small"><i style="" class="el-icon-loading"></i>加载中...</el-button>
  142. </span>
  143. </div>
  144. </div>
  145. </el-card>
  146. <el-card class="box-log" v-if="log">
  147. <div slot="header" class="clearfix">
  148. <span>日志查看(${ currentProcess.name })</span>
  149. <span style="float: right;">
  150. <el-button size="small" @click="clearLog" type="info">清除日志<i style="" class="el-icon-caret-right el-icon--right"></i></el-button>
  151. <el-button size="small" @click="reloadLog" type="success">重载<i style="" class="el-icon-caret-right el-icon--right"></i></el-button>
  152. </span>
  153. </div>
  154. <div class="text item" style="height:800px;overflow:auto">
  155. ${ log[0] || '还没有日志哦' }
  156. </div>
  157. </el-card>
  158. </div>
  159. </div>
  160. </div>
  161. @include('public.admin.mylink')
  162. @endsection
  163. @section('js')
  164. <script>
  165. let service_type = {{$service_type}};
  166. new Vue({
  167. el: '#app',
  168. delimiters: ['${', '}'],
  169. data: {
  170. list:[],
  171. log:'',
  172. state:[],
  173. currentProcess:'',
  174. currentHostname:'',
  175. currentIndex:0,
  176. lodingState: false,
  177. stopAllState: false,
  178. startAllState: false,
  179. restartState: false,
  180. logIndex:'',
  181. service_type:service_type,
  182. queue_color: [{
  183. color: 'green',
  184. value: 'success',
  185. label: '正常'
  186. }, {
  187. color: 'yellow',
  188. value: 'warning',
  189. label: '延迟'
  190. }, {
  191. color: 'red',
  192. value: 'danger',
  193. label: '阻塞'
  194. }, {
  195. color: 'not_open',
  196. value: '',
  197. label: '无'
  198. }, {
  199. color: 'unconnection',
  200. value: 'danger',
  201. label: '连接失败'
  202. }, {
  203. color: 'unexecute',
  204. value: 'danger',
  205. label: '无法使用'
  206. }, {
  207. color: 'uninstall',
  208. value: 'danger',
  209. label: '未安装'
  210. }, {
  211. color: 'not_running',
  212. value: 'danger',
  213. label: '未运行'
  214. }],
  215. queue_hearteat: {
  216. 'daemon': {
  217. queue_status: 'not_running',
  218. is_repeat: 0,
  219. },
  220. 'cron': {
  221. queue_status: 'not_open',
  222. is_repeat: 0,
  223. },
  224. 'job': {
  225. queue_status: 'not_open',
  226. is_repeat: 0,
  227. },
  228. 'redis': {
  229. queue_status: 'not_open',
  230. is_repeat: 0,
  231. }
  232. },
  233. },
  234. methods: {
  235. processlist () {
  236. console.log('processlist');
  237. var that = this;
  238. let url = "{!! yzWebUrl("supervisord.supervisord.process") !!}";
  239. //console.log(url);
  240. axios.get(url)
  241. .then(function (response) {
  242. console.log('response1231234:', response.data);
  243. that.list = response.data.process;
  244. console.log(that.list);
  245. that.state = response.data.state;
  246. console.log('that.state:', that.state);
  247. that.queue_hearteat = response.data.queue_hearteat;
  248. that.queue_hearteat_icon = response.data.queue_hearteat_icon;
  249. })
  250. .catch(function (error) {
  251. console.log('error:', error);
  252. //that.$Message.error('提交失败啦');
  253. });
  254. },
  255. stopAll () {
  256. console.log('stopAll');
  257. var that = this;
  258. this.$confirm('确定要重启所有进程?', '提示', {
  259. confirmButtonText: '确定',
  260. cancelButtonText: '取消',
  261. type: 'warning'
  262. }).then(() => {
  263. that.stopAllState = true;
  264. let url = "{!! yzWebUrl("supervisord.supervisord.stopAll") !!}";
  265. //console.log(url);
  266. axios.get(url)
  267. .then(function (response) {
  268. console.log('response:', response.data);
  269. that.$message({
  270. message: '已停止所有进程',
  271. type: 'success'
  272. });
  273. that.stopAllState = false;
  274. that.processlist();
  275. })
  276. //that.$Message.success('提交成功啦');
  277. .catch(function (error) {
  278. console.log('error:', error);
  279. //that.$Message.error('提交失败啦');
  280. });
  281. }).catch(() => {
  282. this.$message({
  283. type: 'info',
  284. message: '已取消'
  285. });
  286. });
  287. },
  288. startAll () {
  289. console.log('startAll');
  290. var that = this;
  291. let url = "{!! yzWebUrl("supervisord.supervisord.startAll") !!}";
  292. //console.log(url);
  293. this.startAllState = true;
  294. console.log('this.startAllState', this.startAllState);
  295. axios.get(url)
  296. .then(function (response) {
  297. console.log('response:', response.data);
  298. that.$message({
  299. message: '已启动所有进程',
  300. type: 'success'
  301. });
  302. that.startAllState = false;
  303. console.log('this.startAllState', that.startAllState);
  304. that.processlist();
  305. //that.$Message.success('提交成功啦');
  306. })
  307. .catch(function (error) {
  308. console.log('error:', error);
  309. //that.$Message.error('提交失败啦');
  310. });
  311. },
  312. restart () {
  313. console.log('restart');
  314. var that = this;
  315. this.$confirm('确认重启?', '提示', {
  316. confirmButtonText: '确定',
  317. cancelButtonText: '取消',
  318. type: 'warning'
  319. }).then(() => {
  320. //todo
  321. that.restartState = true;
  322. let url = "{!! yzWebUrl("supervisord.supervisord.restart") !!}";
  323. //console.log(url);
  324. axios.get(url)
  325. .then(function (response) {
  326. console.log('restart response:', response.data);
  327. that.$message({
  328. message: '重启中,请稍后',
  329. type: 'info'
  330. });
  331. console.log('restart message:', '完毕');
  332. setTimeout(function(){
  333. that.processlist();
  334. that.$message({
  335. message: '重启完毕',
  336. type: 'success'
  337. });
  338. console.log('restart message:', 'list完毕');
  339. }, 5000);
  340. that.restartState = false;
  341. //that.$Message.success('提交成功啦');
  342. })
  343. .catch(function (error) {
  344. console.log('error:', error);
  345. //that.$Message.error('提交失败啦');
  346. });
  347. }).catch(() => {
  348. this.$message({
  349. type: 'info',
  350. message: '已取消重启'
  351. });
  352. });
  353. return;
  354. },
  355. showlog (process, index=0 ,hostname = '') {
  356. var that = this;
  357. that.list[hostname].val[index].cstate = true;
  358. let url = "{!! yzWebUrl("supervisord.supervisord.showlog") !!}"+"&hostname="+hostname+"&process="+process.group + ":" + process.name;
  359. console.log(url);
  360. axios.get(url)
  361. .then(function (response) {
  362. console.log('response:', response.data);
  363. if (response.data.errno == 0) {
  364. that.log = response.data.val;
  365. that.currentProcess = process;
  366. that.currentHostname = hostname;
  367. that.currentIndex = index;
  368. that.list[hostname].val[index].cstate = false;
  369. } else {
  370. that.list[hostname].val[index].cstate = false;
  371. that.$message.error('错了哦,' + response.data.errstr);
  372. }
  373. //that.$Message.success('提交成功啦');
  374. })
  375. .catch(function (error) {
  376. console.log('error:', error);
  377. //that.$Message.error('提交失败啦');
  378. });
  379. },
  380. clearLog () {
  381. var that = this;
  382. //停止状态清除无效
  383. if (this.currentProcess.state == 0) {
  384. this.$message.error('进程必须启动状态才能清除哦');
  385. return false;
  386. }
  387. let url = "{!! yzWebUrl("supervisord.supervisord.clearlog") !!}"+"&hostname="+this.currentHostname+"&process="+this.currentProcess.group + ":" + this.currentProcess.name;
  388. console.log(url);
  389. axios.get(url)
  390. .then(function (response) {
  391. //console.log('response:', response.data);
  392. if (response.data.errno == 0) {
  393. that.$message({
  394. message: '日志已清除',
  395. type: 'success'
  396. });
  397. that.reloadLog();
  398. } else {
  399. that.$message.error('错了哦,' + response.data.errstr);
  400. }
  401. //that.$Message.success('提交成功啦');
  402. })
  403. .catch(function (error) {
  404. console.log('error:', error);
  405. //that.$Message.error('提交失败啦');
  406. });
  407. },
  408. reloadLog () {
  409. this.showlog(this.currentProcess,this.currentIndex,this.currentHostname);
  410. },
  411. stop (process,hostname) {
  412. console.log('stop');
  413. var that = this;
  414. let url = "{!! yzWebUrl("supervisord.supervisord.stop") !!}"+"&hostname="+hostname+"&process="+process.group + ":" + process.name;
  415. //console.log(url);
  416. axios.get(url)
  417. .then(function (response) {
  418. console.log('response:', response.data);
  419. if (response.data.val) {
  420. that.$message({
  421. message: '进程已停止',
  422. type: 'success'
  423. });
  424. that.processlist();
  425. } else {
  426. that.$message.error('错了哦,' + response.data.errstr);
  427. }
  428. //that.$Message.success('提交成功啦');
  429. })
  430. .catch(function (error) {
  431. console.log('error:', error);
  432. //that.$Message.error('提交失败啦');
  433. });
  434. },
  435. start (process,hostname) {
  436. console.log('start');
  437. var that = this;
  438. let url = "{!! yzWebUrl("supervisord.supervisord.start") !!}"+"&hostname="+hostname+"&process="+process.group + ":" + process.name;
  439. //console.log(url);
  440. axios.get(url)
  441. .then(function (response) {
  442. //console.log('response:', response.data);
  443. if (response.data.val) {
  444. that.$message({
  445. message: '进程已启动',
  446. type: 'success'
  447. });
  448. that.processlist();
  449. } else {
  450. that.$message.error('错了哦,' + response.data.errstr);
  451. }
  452. //that.$Message.success('提交成功啦');
  453. })
  454. .catch(function (error) {
  455. console.log('error:', error);
  456. //that.$Message.error('提交失败啦');
  457. });
  458. }
  459. },
  460. mounted () {
  461. console.log('mounted');
  462. this.processlist();
  463. }
  464. })
  465. </script>
  466. @endsection('js')