mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-18 23:45:52 +08:00
update
This commit is contained in:
@@ -53,6 +53,22 @@ def add():
|
||||
port = request.form.get('port', '')
|
||||
return MwSites.instance().add(webinfo, port, ps, path, version)
|
||||
|
||||
# 站点停止
|
||||
@blueprint.route('/stop', endpoint='stop',methods=['POST'])
|
||||
@panel_login_required
|
||||
def stop():
|
||||
site_id = request.form.get('id', '')
|
||||
site_name = request.form.get('name', '')
|
||||
return MwSites.instance().stop(site_id, site_name)
|
||||
|
||||
# 站点开启
|
||||
@blueprint.route('/start', endpoint='start',methods=['POST'])
|
||||
@panel_login_required
|
||||
def start():
|
||||
site_id = request.form.get('id', '')
|
||||
site_name = request.form.get('name', '')
|
||||
return MwSites.instance().start(site_id, site_name)
|
||||
|
||||
# 添加站点 - 域名
|
||||
@blueprint.route('/add_domain', endpoint='add_domain',methods=['POST'])
|
||||
@panel_login_required
|
||||
|
||||
@@ -106,6 +106,7 @@ def setSitesData(site_id,
|
||||
edate: str | None = None,
|
||||
ps: str | None = None,
|
||||
path: str | None = None,
|
||||
status: str | None = None,
|
||||
):
|
||||
update_data = {}
|
||||
if edate is not None:
|
||||
@@ -116,5 +117,8 @@ def setSitesData(site_id,
|
||||
if path is not None:
|
||||
update_data['path'] = path
|
||||
|
||||
if status is not None:
|
||||
update_data['status'] = status
|
||||
|
||||
return mw.M('sites').where('id=?',(site_id,)).update(update_data)
|
||||
|
||||
|
||||
@@ -211,6 +211,53 @@ class sites(object):
|
||||
mw.restartWeb()
|
||||
return mw.returnData(True, '添加成功')
|
||||
|
||||
def stop(self, site_id, site_name):
|
||||
path = self.setupPath + '/stop'
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
default_text = 'The website has been closed!!!'
|
||||
mw.writeFile(path + '/index.html', default_text)
|
||||
|
||||
binding = thisdb.getBindingListBySiteId(site_id)
|
||||
for b in binding:
|
||||
bpath = path + '/' + b['path']
|
||||
if not os.path.exists(bpath):
|
||||
mw.execShell('mkdir -p ' + bpath)
|
||||
mw.execShell('ln -sf ' + path +'/index.html ' + bpath + '/index.html')
|
||||
|
||||
site_info = thisdb.getSitesById(site_id)
|
||||
|
||||
# nginx
|
||||
file = self.getHostConf(site_name)
|
||||
conf = mw.readFile(file)
|
||||
if conf:
|
||||
conf = conf.replace(site_info['path'], path)
|
||||
mw.writeFile(file, conf)
|
||||
|
||||
thisdb.setSitesData(site_id, status='0')
|
||||
msg = mw.getInfo('网站[{1}]已被停用!', (site_name,))
|
||||
mw.writeLog('网站管理', msg)
|
||||
mw.restartWeb()
|
||||
return mw.returnData(True, '站点已停用!')
|
||||
|
||||
def start(self, site_id, site_name):
|
||||
path = self.setupPath + '/stop'
|
||||
|
||||
site_info = thisdb.getSitesById(site_id)
|
||||
# nginx
|
||||
file = self.getHostConf(site_name)
|
||||
conf = mw.readFile(file)
|
||||
if conf:
|
||||
conf = conf.replace(path, site_info['path'])
|
||||
mw.writeFile(file, conf)
|
||||
|
||||
thisdb.setSitesData(site_id, status='1')
|
||||
|
||||
msg = mw.getInfo('网站[{1}]已被启用!', (site_name,))
|
||||
mw.writeLog('网站管理', msg)
|
||||
mw.restartWeb()
|
||||
return mw.returnData(True, '站点已启用!')
|
||||
|
||||
def nginxAddDomain(self, site_name, domain, port):
|
||||
file = self.getHostConf(site_name)
|
||||
conf = mw.readFile(file)
|
||||
|
||||
Reference in New Issue
Block a user