rabin 7 роки тому
батько
коміт
2faf57757a
3 змінених файлів з 48 додано та 1 видалено
  1. 32 0
      admin/page/hardware.py
  2. 11 0
      admin/static/js/main.js
  3. 5 1
      admin/templates/common/list.html

+ 32 - 0
admin/page/hardware.py

@@ -73,6 +73,7 @@ class type_path(Load):
 		self.common(
 			name = u'硬件类型'
 			,path = '/hardware/type'
+			,button = ({'name':'重启守护进程','link':'/hardware/restart_cron','ajax':True,'icon':''},{'name':'重启mqtt订阅服务','link':'/hardware/restart_sub','ajax':True,'icon':''},{'name':'重启园区服务','link':'/hardware/restart_front','ajax':True,'icon':''},{'name':'重启后台服务','link':'/hardware/restart_admin','ajax':True,'icon':''},{'name':'重启网站服务','link':'/hardware/restart_web','ajax':True,'icon':''})
 			,width = '600'
 			,height = '300'
 			,search = (('name-input-mlike',), (u'类型名称',))
@@ -102,3 +103,34 @@ class type_update_path(Load):
 	@Web.setting
 	def delete(self):
 		self.commonDelete('hardware_type')
+
+class restart_cron_path(Load):
+	@Web.auth
+	@Web.setting
+	def post(self):
+		Shell.popen('ps -ef | grep cron.py | grep -v grep |awk '{print $1}'|xargs kill -9')
+		Shell.popen('./cron.py >/dev/null &')
+
+class restart_sub_path(Load):
+	@Web.auth
+	@Web.setting
+	def post(self):
+		Shell.popen('ps -ef | grep sub.py | grep -v grep |awk '{print $1}'|xargs kill -9')
+
+class restart_admin_path(Load):
+	@Web.auth
+	@Web.setting
+	def post(self):
+		Shell.popen('ps -ef | grep admin.py | grep -v grep |awk '{print $1}'|xargs kill -9')
+
+class restart_front_path(Load):
+	@Web.auth
+	@Web.setting
+	def post(self):
+		Shell.popen('ps -ef | grep front.py | grep -v grep |awk '{print $1}'|xargs kill -9')
+
+class restart_web_path(Load):
+	@Web.auth
+	@Web.setting
+	def post(self):
+		Shell.popen('ps -ef | grep web.py | grep -v grep |awk '{print $1}'|xargs kill -9')

+ 11 - 0
admin/static/js/main.js

@@ -144,6 +144,17 @@ function rec(obj, id, url) {
     });
 }
 
+function oper(name, url) {
+    layer.confirm('确认要'+name+'吗?',function(index){
+    	data = {}
+       	request('post', url, data, function(msg)
+        {
+    		notice('操作成功');
+        })
+    });
+}
+
+
 function delAll() {
     layer.confirm('确认要删除吗?',function(index){
         //捉到所有被选中的,发异步进行删除

+ 5 - 1
admin/templates/common/list.html

@@ -50,7 +50,11 @@
 
     {% if 'button' in data['common'] %}
     {% for value in data['common']['button'] %}
-    <button class="layui-btn" onclick="show('{{value['name']}}','{{value['link']}}','{{data['common']['width']}}','{{data['common']['height']}}'{% if 'full' in data['common'] %},'{{data['common']['full']}}'{% end %})"><i class="layui-icon">&#xe608;</i>{{value['name']}}</button>
+    {% if 'ajax' in value %}
+    <button class="layui-btn" onclick="oper('{{value['name']}}','{{value['link']}}')"><i class="layui-icon">{% if 'icon' in value %}{% raw value['icon'] %}{% else %}&#xe608;{% end %}</i>{{value['name']}}</button>
+    {% else %}
+    <button class="layui-btn" onclick="show('{{value['name']}}','{{value['link']}}','{{data['common']['width']}}','{{data['common']['height']}}'{% if 'full' in data['common'] %},'{{data['common']['full']}}'{% end %})"><i class="layui-icon">{% if 'icon' in value %}{% raw value['icon'] %}{% else %}&#xe608;{% end %}</i>{{value['name']}}</button>
+    {% end %}
     {% end %}
     {% end %}
   {% else %}