dever 5 years ago
parent
commit
3a0806eb21

+ 76 - 104
admin/page/deploy.py

@@ -1,159 +1,131 @@
 # -*- coding: utf-8 -*-
 """
     demeter web page
-    name:score.py 积分相关
+    name:deploy.py 上线代码相关
     author:rabin
 """
 from .__load__ import *
 
-class score_path(Load):
+class project_path(Load):
 	@Web.auth
 	@Web.setting
 	def get(self):
 		self.set(
-			name = u'积分设置'
-			,path = '/score/score'
-			,width = '600'
-			,height = '600'
-			,search = (('label-1','cdate-time-start','cdate-time-end'), (u'日期范围',u'开始时间',u'截止时间'))
-			,thead = (u'积分名', u'规则', u'更新时间')
-			,tbody = ('name', 'func', 'cdate')
+			name = u'项目管理'
+			,path = '/deploy/project'
+			,width = '500'
+			,height = '500'
+			,search = (('label-1','cdate-time-start','cdate-time-end','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'项目名称'))
+			,thead = (u'项目ID', u'项目名称', u'更新时间')
+			,tbody = ('id','name', 'cdate')
 			,state = True
 		)
 
-		menu = (
-			{'name':'规则列表', 'url':'/score/score_rule'},
-			)
-
-		self.list('score')
-		if self.data['list']:
-			for key, value in enumerate(self.data['list']):
-				id = str(value['id'])
-				param = '?score_id=' + id + '&search_score_id-select-=' + id
-				self.data['list'][key]['func'] = ''
-				for i in menu:
-					self.data['list'][key]['func'] = self.data['list'][key]['func'] + '<a href="'+i['url']+''+param+'">'+i['name']+'</a>&nbsp;&nbsp;&nbsp;&nbsp;'
-
+		self.list('project')
 		self.show('list')
 
-class score_update_path(Load):
+class project_update_path(Load):
 	@Web.auth
 	@Web.setting
 	def get(self):
 		self.set(
-			path = '/score/score'
-			,label = (u'积分名称',)
-			,update = ('name-input-required',)
+			path = '/deploy/project'
+			,label = (u'项目名称',u'项目key',u'节点id',u'git地址',u'可写目录-多个用换行隔开,直接填写可写目录名称即可',u'配置目录-多个用换行隔开,直接填写配置目录名称即可')
+			,update = ('name-input-required','key-input-required','node_id-checkbox-required','git-input-required','write-text--data/','config-text--config/env/')
+			,update_node_id = self.service('common').list('node')
 		)
-		self.one('score')
+		self.one('project')
 		self.show('update')
 	@Web.auth
 	@Web.setting
 	def post(self):
-		self.update('score')
-	@Web.auth
-	@Web.setting
-	def delete(self):
-		self.drop('score')
 
-class score_rule_path(Load):
-	@Web.auth
-	@Web.setting
-	def get(self):
-		id = str(self.input('score_id'))
-		param = '?score_id=' + id + '&search_score_id-select-=' + id
-		self.set(
-			name = u'积分规则设置'
-			,path = '/score/score_rule'
-			,width = '600'
-			,height = '600'
-			,search = (('label-1','cdate-time-start','cdate-time-end','search_score_id-select-','record_type_id-select-'), (u'日期范围',u'开始时间',u'截止时间', u'选择积分', u'选择记录点类型'))
-			,thead = (u'积分名', u'记录点类型', u'规则', u'更新时间')
-			,tbody = ('name', 'type', 'rule', 'cdate')
-			,state = True
-		)
+		if 'git_path' in Demeter.config['admin']:
+			path = Demeter.config['admin']['git_path']
+			git = self.data['update']['git']
+			name = self.data['update']['key']
+			project = path + name
+			if not File.exists(project):
+				Shell.popen('cd ' + path + ' && git clone ' + git + ' ' + name, bg=True)
 
-		self.data['common']['search_record_type_id-select-'] = self.service('common').list('record_type')
-
-		self.data['common']['search_score_id-select-'] = self.service('common').list('score')
-
-		self.list('score_rule')
-		if self.data['list']:
-			for key, value in enumerate(self.data['list']):
-				typeData = self.service('common').one('record_type', id=value['record_type_id'])
-				self.data['list'][key]['type'] = typeData['name']
-
-				score = self.service('common').one('score', id=value['score_id'])
-				self.data['list'][key]['name'] = score['name']
-
-		self.show('list')
-
-class score_rule_update_path(Load):
-	@Web.auth
-	@Web.setting
-	def get(self):
-		self.set(
-			path = '/score/score_rule'
-			,label = (u'积分ID', u'记录点类型', u'积分规则公式')
-			,update = ('score_id-select-required','record_type_id-select-required','rule-text-required')
-			,update_record_type_id = self.service('common').list('record_type')
-			,update_score_id = self.service('common').list('score')
-		)
-		self.one('score_rule')
-		self.show('update')
-	@Web.auth
-	@Web.setting
-	def post(self):
-		self.update('score_rule')
+		self.update('project')
 	@Web.auth
 	@Web.setting
 	def delete(self):
-		self.drop('score_rule')
+		self.drop('project')
+
 
-class level_path(Load):
+class submit_path(Load):
 	@Web.auth
 	@Web.setting
 	def get(self):
-		id = str(self.input('score_id'))
-		param = '?score_id=' + id + '&search_score_id-select-=' + id
 		self.set(
-			name = u'等级设置'
-			,path = '/score/level'
-			,width = '600'
-			,height = '600'
-			,search = (('label-1','cdate-time-start','cdate-time-end','search_score_id-select-'), (u'日期范围',u'开始时间',u'截止时间', u'选择积分'))
-			,thead = (u'等级名',u'积分名', u'规则', u'更新时间')
-			,tbody = ('name', 'score', 'rule', 'cdate')
+			name = u'代码提交'
+			,path = '/deploy/submit'
+			,width = '500'
+			,height = '500'
+			,search = (('label-1','cdate-time-start','cdate-time-end','file-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'提交文件'))
+			,thead = (u'提交ID', u'所属项目', u'提交文件', u'提交描述', u'提交人', u'提交时间')
+			,tbody = ('id','project','file','desc','admin', 'cdate')
 			,state = True
 		)
 
-		self.data['common']['search_score_id-select-'] = self.service('common').list('score')
-
-		self.list('level')
+		self.list('code')
 		if self.data['list']:
 			for key, value in enumerate(self.data['list']):
-				score = self.service('common').one('score', id=value['score_id'])
-				self.data['list'][key]['score'] = score['name']
+				project = self.service('common').one('project', id=value['project_id'])
+				self.data['list'][key]['project'] = project['name']
 
+				admin = self.service('common').one('manage_admin', id=value['admin'])
+				self.data['list'][key]['admin'] = admin['username']
 		self.show('list')
 
-class level_update_path(Load):
+class submit_update_path(Load):
 	@Web.auth
 	@Web.setting
 	def get(self):
 		self.set(
-			path = '/score/level'
-			,label = (u'等级名', u'积分ID', u'规则公式')
-			,update = ('name-input-required','score_id-select-required','rule-text-required')
-			,update_score_id = self.service('common').list('score')
+			path = '/deploy/submit'
+			,label = (u'所属项目',u'提交文件-多个换行隔开',u'提交描述')
+			,update = ('project_id-select-required','file-text-required','desc-text-required')
+			,update_project_id = self.service('common').list('project')
 		)
-		self.one('level')
+		self.one('code')
 		self.show('update')
 	@Web.auth
 	@Web.setting
 	def post(self):
-		self.update('level')
+
+		self.data['update']['admin'] = self.data['setting']['admin']
+		if 'git_path' in Demeter.config['admin'] and 'online_path' in Demeter.config['admin']:
+			path = Demeter.config['admin']['git_path']
+			online = Demeter.config['admin']['online_path']
+			project_id = self.data['update']['project_id']
+			project_info = self.service('common').one('project', id=project_id)
+			write = project_info['write'].split("\r\n")
+			config = project_info['config'].split("\r\n")
+			name = project_info['key']
+			file = self.data['update']['file']
+			project = path + name + '/'
+			online_project = online + name + '/'
+			if File.exists(project):
+				if not File.exists(online_project) or file == '/':
+					command = 'cp -R ' + project + ' ' + online_project + ' && rm -rf '+online_project+'.git/ && chmod -R 777 ' + online_project + 'data/'
+				else:
+					file = file.split("\r\n")
+					files = []
+					for i in file:
+						c = 'cp -R ' + project + i + ' ' + online_project + i + ' '
+						for j in write:
+							if j in i:
+								c = c + ' && chmod -R 777 ' + online_project + i + ' '
+						files.append(c)
+					command = '&&'.join(files)
+
+				Shell.popen('cd ' + project + ' && git pull && ' + command, bg=True)
+
+		self.update('code')
 	@Web.auth
 	@Web.setting
 	def delete(self):
-		self.drop('level')
+		self.drop('code')

+ 196 - 20
admin/page/server.py

@@ -6,15 +6,186 @@
 """
 from .__load__ import *
 
+class domain_path(Load):
+	@Web.auth
+	@Web.setting
+	def get(self):
+		self.set(
+			name = u'域管理'
+			,path = '/server/domain'
+			,width = '500'
+			,height = '200'
+			,search = (('label-1','cdate-time-start','cdate-time-end','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'域名称'))
+			,thead = (u'域ID', u'域名称', u'更新时间')
+			,tbody = ('id','name', 'cdate')
+			,state = True
+		)
+
+		self.list('domain')
+		self.show('list')
+
+class domain_update_path(Load):
+	@Web.auth
+	@Web.setting
+	def get(self):
+		self.set(
+			path = '/server/domain'
+			,label = (u'域名称',)
+			,update = ('name-input-required',)
+		)
+		self.one('domain')
+		self.show('update')
+	@Web.auth
+	@Web.setting
+	def post(self):
+		self.update('domain')
+	@Web.auth
+	@Web.setting
+	def delete(self):
+		self.drop('domain')
+
+class node_path(Load):
+	@Web.auth
+	@Web.setting
+	def get(self):
+		self.set(
+			name = u'节点管理'
+			,path = '/server/node'
+			,width = '500'
+			,height = '300'
+			,search = (('label-1','cdate-time-start','cdate-time-end','domain_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'选择域', u'节点名称'))
+			,thead = (u'节点ID', u'节点名称', u'域名', u'节点IP', u'更新时间')
+			,tbody = ('id', 'name', 'domain', 'ip', 'cdate')
+			,state = True
+		)
+
+		self.data['common']['search_domain_id-select-'] = self.service('common').list('domain')
+
+		self.list('node')
+		if self.data['list']:
+			for key, value in enumerate(self.data['list']):
+				data = self.service('common').one('domain', id=value['domain_id'])
+				self.data['list'][key]['domain'] = data['name']
+
+		self.show('list')
+
+class node_update_path(Load):
+	@Web.auth
+	@Web.setting
+	def get(self):
+		self.set(
+			path = '/server/node'
+			,label = (u'节点名称', u'选择域', u'节点IP')
+			,update = ('name-input-required','domain_id-select-required', 'ip-input-required')
+			,update_domain_id = self.service('common').list('domain')
+		)
+		self.one('node')
+		self.show('update')
+	@Web.auth
+	@Web.setting
+	def post(self):
+		self.update('node')
+	@Web.auth
+	@Web.setting
+	def delete(self):
+		self.drop('node')
+
+
+
+class category_path(Load):
+	@Web.auth
+	@Web.setting
+	def get(self):
+		self.set(
+			name = u'镜像分类管理'
+			,path = '/server/category'
+			,width = '500'
+			,height = '200'
+			,search = (('label-1','cdate-time-start','cdate-time-end','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'分类名称'))
+			,thead = (u'分类ID', u'分类名称', u'更新时间')
+			,tbody = ('id','name', 'cdate')
+			,state = True
+		)
+
+		self.list('category')
+		self.show('list')
+
+class category_update_path(Load):
+	@Web.auth
+	@Web.setting
+	def get(self):
+		self.set(
+			path = '/server/category'
+			,label = (u'分类名称',)
+			,update = ('name-input-required',)
+		)
+		self.one('category')
+		self.show('update')
+	@Web.auth
+	@Web.setting
+	def post(self):
+		self.update('category')
+	@Web.auth
+	@Web.setting
+	def delete(self):
+		self.drop('category')
+
+class images_path(Load):
+	@Web.auth
+	@Web.setting
+	def get(self):
+		self.set(
+			name = u'镜像管理'
+			,path = '/server/images'
+			,width = '500'
+			,height = '300'
+			,search = (('label-1','cdate-time-start','cdate-time-end','category_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'选择分类', u'镜像名称'))
+			,thead = (u'镜像ID', u'镜像名称', u'分类', u'更新时间')
+			,tbody = ('id', 'name', 'category', 'cdate')
+			,state = True
+		)
+
+		self.data['common']['search_category_id-select-'] = self.service('common').list('category')
+
+		self.list('images')
+		if self.data['list']:
+			for key, value in enumerate(self.data['list']):
+				data = self.service('common').one('category', id=value['category_id'])
+				self.data['list'][key]['category'] = data['name']
+
+		self.show('list')
+
+class images_update_path(Load):
+	@Web.auth
+	@Web.setting
+	def get(self):
+		self.set(
+			path = '/server/images'
+			,label = (u'镜像名称', u'选择分类')
+			,update = ('name-input-required','category_id-select-required')
+			,update_category_id = self.service('common').list('category')
+		)
+		self.one('images')
+		self.show('update')
+	@Web.auth
+	@Web.setting
+	def post(self):
+		self.update('images')
+	@Web.auth
+	@Web.setting
+	def delete(self):
+		self.drop('images')
+
+
 class group_path(Load):
 	@Web.auth
 	@Web.setting
 	def get(self):
 		self.set(
-			name = u'组管理'
+			name = u'容器分组管理'
 			,path = '/server/group'
-			,width = '600'
-			,height = '600'
+			,width = '500'
+			,height = '200'
 			,search = (('label-1','cdate-time-start','cdate-time-end','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'组名称'))
 			,thead = (u'组ID', u'组名称', u'更新时间')
 			,tbody = ('id','name', 'cdate')
@@ -44,48 +215,53 @@ class group_update_path(Load):
 	def delete(self):
 		self.drop('group')
 
-class node_path(Load):
+class container_path(Load):
 	@Web.auth
 	@Web.setting
 	def get(self):
 		self.set(
-			name = u'节点管理'
-			,path = '/server/node'
-			,width = '600'
-			,height = '600'
-			,search = (('label-1','cdate-time-start','cdate-time-end','group_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'选择组', u'节点名称'))
-			,thead = (u'节点ID', u'节点名称', u'组名', u'节点IP', u'更新时间')
-			,tbody = ('id', 'name', 'group', 'ip', 'cdate')
+			name = u'容器管理'
+			,path = '/server/container'
+			,width = '500'
+			,height = '300'
+			,search = (('label-1','cdate-time-start','cdate-time-end','group_id-select-','images_id-select-','name-input-mlike'), (u'日期范围',u'开始时间',u'截止时间',u'选择分组',u'选择镜像', u'容器名称'))
+			,thead = (u'容器ID', u'容器名称', u'分组', u'镜像', u'更新时间')
+			,tbody = ('id', 'name', 'group', 'images', 'cdate')
 			,state = True
 		)
 
 		self.data['common']['search_group_id-select-'] = self.service('common').list('group')
+		self.data['common']['search_images_id-select-'] = self.service('common').list('images')
 
-		self.list('node')
+		self.list('container')
 		if self.data['list']:
 			for key, value in enumerate(self.data['list']):
 				data = self.service('common').one('group', id=value['group_id'])
-				self.data['list'][key]['type'] = data['name']
+				self.data['list'][key]['group'] = data['name']
+
+				data = self.service('common').one('images', id=value['images_id'])
+				self.data['list'][key]['images'] = data['name']
 
 		self.show('list')
 
-class node_update_path(Load):
+class container_update_path(Load):
 	@Web.auth
 	@Web.setting
 	def get(self):
 		self.set(
-			path = '/server/node'
-			,label = (u'节点名称', u'选择组', u'节点IP')
-			,update = ('name-input-required','group_id-select-required', 'ip-input-required')
+			path = '/server/container'
+			,label = (u'容器名称', u'选择分组', u'选择镜像')
+			,update = ('name-input-required','group_id-select-required','images_id-select-required')
 			,update_group_id = self.service('common').list('group')
+			,update_images_id = self.service('common').list('images')
 		)
-		self.one('node')
+		self.one('container')
 		self.show('update')
 	@Web.auth
 	@Web.setting
 	def post(self):
-		self.update('node')
+		self.update('container')
 	@Web.auth
 	@Web.setting
 	def delete(self):
-		self.drop('node')
+		self.drop('container')

+ 10 - 3
conf/dev.conf

@@ -1,7 +1,7 @@
 [base]
 ;开发环境配置
 [setting]
-name				= DM管理系统
+name				= DM运维管理系统
 site				= http://www.dever.cc/
 copyright			= 2018 dever.cc v1.0.0
 ;打印路由表
@@ -33,9 +33,12 @@ max_buffer_size		= 210763776
 ;子进程
 process				= 0
 ;定义后台父级菜单
-menu_parent			= 服务器设置:&#xe62e;,代码上线:&#xe62e;
+menu_parent			= 资源管理:&#xe62e;,代码管理:&#xe62e;
 ;定义后台子级菜单
-menu_child			= 组设置:/server/group,节点管理:/server/node;项目管理:/deploy/project,提交代码:/deploy/submit,代码审核:/deploy/look,文档管理:/deploy/doc
+menu_child			= 域管理:/server/domain,节点管理:/server/node,镜像分类管理:/server/category,镜像管理:/server/images,容器分组管理:/server/group,容器管理:/server/container;项目管理:/deploy/project,提交代码:/deploy/submit
+
+;;,进程管理:&#xe62e
+;进程管理:/process/process;
 
 ;cookie
 cookie_secret       = 61oETzKXQAGaYekL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=
@@ -43,6 +46,10 @@ login_url           = /user/login
 ;是否使用安全cookie
 xsrf_cookies        = True
 
+;上线的路径
+git_path			= /data/dm/container/share/lib/web/
+online_path			= /data/dm/container/web/
+
 ;前台配置
 [front]
 port				= 8088

+ 23 - 13
conf/env.conf

@@ -1,22 +1,25 @@
 [base]
-;线上环境配置,请设置环境变量DEMETER_CONF = env
+;开发环境配置
 [setting]
-name				= 抢购平台
+name				= DM运维管理系统
 site				= http://www.dever.cc/
-copyright			= 2017 dever.cc v1.0.0
-phantomjs			= http://192.168.15.10:8910/
+copyright			= 2018 dever.cc v1.0.0
+;打印路由表
+route				= True
 
 [db]
 rdb					= mysql
 
 [mysql]
-host				= 192.168.1.203
-port				= 3307
+host				= daemon-mysql
+port				= 3309
 username			= root
 password			= 123456
-dbname				= demeter
-prefix				= demeter
+dbname				= dm
+prefix				= dm
 charset				= utf8
+;允许自动建表
+create				= True
 
 ;定义一些tornado的配置,可为空
 [tornado]
@@ -30,15 +33,22 @@ max_buffer_size		= 210763776
 ;子进程
 process				= 0
 ;定义后台父级菜单
-menu_parent			= 站点设置:&#xe62e;
+menu_parent			= 资源管理:&#xe62e;,代码管理:&#xe62e;
 ;定义后台子级菜单
-menu_child			= 站点管理:/site/site,抢购商品设置:/site/product
+menu_child			= 域管理:/server/domain,节点管理:/server/node,镜像分类管理:/server/category,镜像管理:/server/images,容器分组管理:/server/group,容器管理:/server/container;项目管理:/deploy/project,提交代码:/deploy/submit
+
+;;,进程管理:&#xe62e
+;进程管理:/process/process;
 
 ;cookie
-cookie_secret		= 61oETzKXQAGaYekL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=
-login_url			= /user/login
+cookie_secret       = 61oETzKXQAGaYekL5gEmGeJJFuYh7EQnp2XdTP1o/Vo=
+login_url           = /user/login
 ;是否使用安全cookie
-xsrf_cookies		= True
+xsrf_cookies        = True
+
+;上线的路径
+git_path			= /data/dm/container/share/lib/web/
+online_path			= /data/dm/container/web/
 
 ;前台配置
 [front]

+ 28 - 0
cron.py

@@ -0,0 +1,28 @@
+# -*- coding: utf-8 -*-
+import time
+from demeter.core import *
+from gevent import monkey; monkey.patch_socket()
+import gevent
+timeSleep = 15
+
+# git更新
+def git():
+	service = Demeter.service('git')
+	while 1:
+		service.update()
+		gevent.sleep(timeSleep)
+
+# 备份 仅仅备份dc即可
+def backup():
+	while 1:
+		service = Demeter.service('backup')
+		service.crearSignature()
+		gevent.sleep(timeSleep)
+
+def handle():
+	gevent.joinall([
+		gevent.spawn(git),
+		#gevent.spawn(backup),
+	])
+
+handle()

+ 14 - 0
model/category.py

@@ -0,0 +1,14 @@
+# -*- coding: utf-8 -*-
+"""
+    demeter database
+    name:category.py 分类表
+"""
+from .__load__ import *
+
+class Category(Model):
+	__table__ = 'category'
+	__comment__ = '镜像分类表'
+	id = Fields(type='int', primaryKey=True, autoIncrement=True, comment='ID')
+	name = Fields(type='varchar(60)', comment='分类名称')
+	state = Fields(type='boolean', default='True', comment='数据存在状态')
+	cdate = Fields(type='int', default='time', comment='创建时间')

+ 18 - 0
model/code.py

@@ -0,0 +1,18 @@
+# -*- coding: utf-8 -*-
+"""
+    demeter database
+    name:code.py 代码提交表
+"""
+from .__load__ import *
+
+class Code(Model):
+	__table__ = 'code'
+	__comment__ = '代码提交表'
+	id = Fields(type='int', primaryKey=True, autoIncrement=True, comment='ID')
+	file = Fields(type='text', comment='文件列表')
+	project_id = Fields(type='int(11)', comment='项目id')
+	desc = Fields(type='varchar(500)', comment='描述')
+	status = Fields(type='int(11)', default='1', comment='1提交2审核通过3审核失败')
+	admin = Fields(type='int(11)', comment='提交人')
+	state = Fields(type='boolean', default='True', comment='数据存在状态')
+	cdate = Fields(type='int', default='time', comment='创建时间')

+ 16 - 0
model/container.py

@@ -0,0 +1,16 @@
+# -*- coding: utf-8 -*-
+"""
+    demeter database
+    name:container.py 容器表
+"""
+from .__load__ import *
+
+class Container(Model):
+	__table__ = 'container'
+	__comment__ = '容器表'
+	id = Fields(type='int', primaryKey=True, autoIncrement=True, comment='ID')
+	group_id = Fields(type='int', comment='组id')
+	images_id = Fields(type='int', comment='镜像id')
+	name = Fields(type='varchar(60)', comment='容器名称')
+	state = Fields(type='boolean', default='True', comment='数据存在状态')
+	cdate = Fields(type='int', default='time', comment='创建时间')

+ 5 - 5
model/score.py → model/domain.py

@@ -1,14 +1,14 @@
 # -*- coding: utf-8 -*-
 """
     demeter database
-    name:score.py 积分
+    name:domain.py 域
 """
 from .__load__ import *
 
-class Score(Model):
-	__table__ = 'score'
-	__comment__ = '积分设置表'
+class Domain(Model):
+	__table__ = 'domain'
+	__comment__ = '表'
 	id = Fields(type='int', primaryKey=True, autoIncrement=True, comment='ID')
-	name = Fields(type='varchar(200)', comment='积分名称')
+	name = Fields(type='varchar(60)', comment='域名称')
 	state = Fields(type='boolean', default='True', comment='数据存在状态')
 	cdate = Fields(type='int', default='time', comment='创建时间')

+ 1 - 1
model/group.py

@@ -9,6 +9,6 @@ class Group(Model):
 	__table__ = 'group'
 	__comment__ = '分组表'
 	id = Fields(type='int', primaryKey=True, autoIncrement=True, comment='ID')
-	name = Fields(type='varchar(200)', comment='分组名称')
+	name = Fields(type='varchar(60)', comment='分组名称')
 	state = Fields(type='boolean', default='True', comment='数据存在状态')
 	cdate = Fields(type='int', default='time', comment='创建时间')

+ 17 - 0
model/images.py

@@ -0,0 +1,17 @@
+# -*- coding: utf-8 -*-
+"""
+    demeter database
+    name:images.py 镜像表
+"""
+from .__load__ import *
+
+class Images(Model):
+	__table__ = 'images'
+	__comment__ = '镜像表'
+	id = Fields(type='int', primaryKey=True, autoIncrement=True, comment='ID')
+	name = Fields(type='varchar(60)', comment='镜像名')
+	category_id = Fields(type='int', comment='分类id')
+	type = Fields(type='int', default='1', comment='类型1为系统镜像2为手动添加的镜像')
+	address = Fields(type='varchar(300)', comment='镜像地址')
+	state = Fields(type='boolean', default='True', comment='数据存在状态')
+	cdate = Fields(type='int', default='time', comment='创建时间')

+ 2 - 2
model/node.py

@@ -9,8 +9,8 @@ class Node(Model):
 	__table__ = 'node'
 	__comment__ = '节点表'
 	id = Fields(type='int', primaryKey=True, autoIncrement=True, comment='ID')
-	name = Fields(type='varchar(200)', comment='节点名')
-	group_id = Fields(type='int', comment='组id')
+	name = Fields(type='varchar(60)', comment='节点名')
+	domain_id = Fields(type='int', comment='域id')
 	ip = Fields(type='varchar(32)', comment='ip地址')
 	state = Fields(type='boolean', default='True', comment='数据存在状态')
 	cdate = Fields(type='int', default='time', comment='创建时间')

+ 17 - 0
model/process.py

@@ -0,0 +1,17 @@
+# -*- coding: utf-8 -*-
+"""
+    demeter database
+    name:process.py 进程表
+"""
+from .__load__ import *
+
+class Process(Model):
+	__table__ = 'process'
+	__comment__ = '进程表'
+	id = Fields(type='int', primaryKey=True, autoIncrement=True, comment='ID')
+	container_id = Fields(type='int', comment='容器id')
+	node_id = Fields(type='int', comment='节点id')
+	name = Fields(type='varchar(60)', comment='进程名称')
+	desc = Fields(type='varchar(500)', comment='进程描述')
+	state = Fields(type='boolean', default='True', comment='数据存在状态')
+	cdate = Fields(type='int', default='time', comment='创建时间')

+ 19 - 0
model/project.py

@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+"""
+    demeter database
+    name:project.py 项目表
+"""
+from .__load__ import *
+
+class Project(Model):
+	__table__ = 'project'
+	__comment__ = '项目表'
+	id = Fields(type='int', primaryKey=True, autoIncrement=True, comment='ID')
+	name = Fields(type='varchar(60)', comment='项目名')
+	node_id = Fields(type='varchar(500)', comment='节点id')
+	git = Fields(type='varchar(500)', comment='git版本库地址')
+	key = Fields(type='varchar(32)', comment='项目英文名')
+	write = Fields(type='text', comment='可写目录')
+	config = Fields(type='text', comment='配置目录')
+	state = Fields(type='boolean', default='True', comment='数据存在状态')
+	cdate = Fields(type='int', default='time', comment='创建时间')

+ 0 - 15
model/record_type.py

@@ -1,15 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-    demeter database
-    name:record_type.py 统计类型记录表,暂时用数据库
-"""
-from .__load__ import *
-
-class Record_type(Model):
-	__table__ = 'record_type'
-	__comment__ = '记录点类型表'
-	id = Fields(type='int', primaryKey=True, autoIncrement=True, comment='ID')
-	name = Fields(type='varchar(200)', comment='操作名')
-	type = Fields(type='int', default='1', comment='操作类型1是浏览2是操作')
-	state = Fields(type='boolean', default='True', comment='数据存在状态')
-	cdate = Fields(type='int', default='time', comment='创建时间')

+ 0 - 17
model/score_rule.py

@@ -1,17 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
-    demeter database
-    name:score.py 积分表
-"""
-from .__load__ import *
-
-class Score_rule(Model):
-	__table__ = 'score_rule'
-	__comment__ = '积分规则表'
-	id = Fields(type='int', primaryKey=True, autoIncrement=True, comment='ID')
-	score_id = Fields(type='int', comment='积分id')
-	record_type_id = Fields(type='int', comment='记录点类型id')
-	uid = Fields(type='varchar(200)', comment='用户id,特殊积分')
-	rule = Fields(type='varchar(800)', comment='积分规则公式')
-	state = Fields(type='boolean', default='True', comment='数据存在状态')
-	cdate = Fields(type='int', default='time', comment='创建时间')

+ 1 - 0
runtime/mysql/category

@@ -0,0 +1 @@
+[["state", 1], ["cdate", 1], ["name", 1], ["id", 1]]

+ 1 - 0
runtime/mysql/code

@@ -0,0 +1 @@
+[["status", 1], ["admin", 1], ["cdate", 1], ["state", 1], ["file", 1], ["project_id", 1], ["id", 1], ["desc", 1]]

+ 1 - 0
runtime/mysql/container

@@ -0,0 +1 @@
+[["name", 1], ["cdate", 1], ["state", 1], ["group_id", 1], ["id", 1], ["images_id", 1]]

+ 1 - 0
runtime/mysql/domain

@@ -0,0 +1 @@
+[["state", 1], ["cdate", 1], ["name", 1], ["id", 1]]

+ 1 - 0
runtime/mysql/group

@@ -0,0 +1 @@
+[["state", 1], ["cdate", 1], ["name", 1], ["id", 1]]

+ 1 - 0
runtime/mysql/images

@@ -0,0 +1 @@
+[["name", 1], ["cdate", 1], ["state", 1], ["address", 1], ["category_id", 1], ["type", 1], ["id", 1]]

+ 0 - 1
runtime/mysql/level

@@ -1 +0,0 @@
-[["name", 1], ["cdate", 1], ["rule", 1], ["state", 1], ["score_id", 1], ["id", 1]]

+ 1 - 0
runtime/mysql/node

@@ -0,0 +1 @@
+[["name", 1], ["ip", 1], ["cdate", 1], ["domain_id", 1], ["state", 1], ["id", 1]]

+ 1 - 0
runtime/mysql/project

@@ -0,0 +1 @@
+[["git", 1], ["name", 1], ["cdate", 1], ["write", 1], ["state", 1], ["node_id", 1], ["key", 1], ["id", 1]]

+ 0 - 1
runtime/mysql/record

@@ -1 +0,0 @@
-[["record_type_id", 1], ["name", 1], ["cdate", 1], ["state", 1], ["ua", 1], ["id", 1], ["uid", 1]]

+ 0 - 1
runtime/mysql/record_type

@@ -1 +0,0 @@
-[["type", 1], ["state", 1], ["cdate", 1], ["name", 1], ["id", 1]]

+ 0 - 1
runtime/mysql/score

@@ -1 +0,0 @@
-[["record_type_id", 1], ["name", 1], ["cdate", 1], ["rule", 1], ["state", 1], ["id", 1], ["uid", 1]]

+ 0 - 1
runtime/mysql/score_rule

@@ -1 +0,0 @@
-[["record_type_id", 1], ["uid", 1], ["cdate", 1], ["rule", 1], ["state", 1], ["score_id", 1], ["id", 1]]

+ 7 - 0
service/__init__.py

@@ -0,0 +1,7 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+    demeter init
+    author:rabin
+    实现具体的业务逻辑,前台、后台、接口都走这一套逻辑,此处可以直接生成接口
+"""

+ 12 - 0
service/__load__.py

@@ -0,0 +1,12 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+    demeter service
+    name:__load__.py
+    author:rabin
+"""
+from demeter.core import *
+from datetime import *
+import uuid
+import os
+import os.path

+ 21 - 0
service/backup.py

@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+from .__load__ import *
+
+# 备份
+class Backup(object):
+
+	def __init__(self):
+		self.path = Demeter.config['admin']['online_path']
+
+	def update(self):
+		path = self.web
+		files = File.getFiles(path)
+		if files:
+			for i in files:
+				file = path + i + '/.git/'
+				if File.exists(file):
+					self.pull(path, i, file)
+
+	def pull(self, path, name, file):
+		path = path + name + '/'
+		Shell.popen('cd ' + path + ' && git pull')

+ 22 - 0
service/git.py

@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+from .__load__ import *
+
+# git实时更新
+class Git(object):
+
+	def __init__(self):
+		self.share = '/share/lib/'
+		self.web = self.share + 'web/'
+
+	def update(self):
+		path = self.web
+		files = File.getFiles(path)
+		if files:
+			for i in files:
+				file = path + i + '/.git/'
+				if File.exists(file):
+					self.pull(path, i, file)
+
+	def pull(self, path, name, file):
+		path = path + name + '/'
+		Shell.popen('cd ' + path + ' && git pull')