站点添加优化

This commit is contained in:
Mr Chen
2018-12-20 13:39:43 +08:00
parent 48aad5b248
commit cccbd88145
2 changed files with 15 additions and 26 deletions
+14 -5
View File
@@ -252,7 +252,7 @@ class site_api:
def nginxAddConf(self):
source_tpl = public.getRunDir() + '/data/tpl/nginx.conf'
desc_file = self.setupPath + '/openresty/nginx/conf/vhost/' + self.siteName + '.conf'
vhost_file = self.setupPath + '/openresty/nginx/conf/vhost/' + self.siteName + '.conf'
content = public.readFile(source_tpl)
content = content.replace('{$PORT}', self.sitePort)
@@ -265,7 +265,11 @@ class site_api:
logsPath = public.getLogsDir()
content = content.replace('{$LOGPATH}', logsPath)
public.writeFile(desc_file, content)
public.writeFile(vhost_file, content)
rewrite_file = self.setupPath + \
'/openresty/nginx/conf/rewrite/' + self.siteName + '.conf'
public.writeFile(rewrite_file, '')
def add(self, webname, port, ps, path, version):
@@ -312,9 +316,14 @@ class site_api:
def delete(self, sid, webname):
confPath = self.setupPath + '/openresty/nginx/conf/vhost/' + webname + '.conf'
if os.path.exists(confPath):
os.remove(confPath)
confFile = self.setupPath + '/openresty/nginx/conf/vhost/' + webname + '.conf'
if os.path.exists(confFile):
os.remove(confFile)
rewriteFile = self.setupPath + '/openresty/nginx/conf/rewrite/' + webname + '.conf'
if os.path.exists(rewriteFile):
os.remove(rewriteFile)
public.M('sites').where("id=?", (sid,)).delete()
return public.returnJson(True, '站点删除成功!')