MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / change_log_path

Method change_log_path

class/projectModel/nodejsModel.py:2213–2239  ·  view source on GitHub ↗

修改日志文件地址 @author baozi <202-03-13> @param: get ( dict ): 请求: 包含项目名称和新的路径 @return

(self, get)

Source from the content-addressed store, hash-verified

2211 return True
2212
2213 def change_log_path(self, get):
2214 """"修改日志文件地址
2215 @author baozi <202-03-13>
2216 @param:
2217 get ( dict ): 请求: 包含项目名称和新的路径
2218 @return
2219 """
2220 project_info = self.get_project_find(get.project_name.strip())
2221 if not project_info: return public.returnMsg(False,'项目不存在')
2222 new_log_path = get.path.strip() if "path" in get else None
2223 if not new_log_path or new_log_path[0] != "/":
2224 return public.returnMsg(False, "路径设置错误")
2225 if new_log_path[-1] == "/": new_log_path = new_log_path[:-1]
2226 if not os.path.exists(new_log_path):
2227 os.makedirs(new_log_path, mode=0o777)
2228 project_info['project_config']['log_path'] = new_log_path
2229 pdata = {
2230 'name': project_info["name"],
2231 'project_config': json.dumps(project_info['project_config'])
2232 }
2233 public.M('sites').where('name=?',(get.project_name.strip(),)).update(pdata)
2234 #重启项目
2235 #return self.restart_project(get)
2236 res = self.stop_project(get)
2237 res = self.start_project(get)
2238 public.WriteLog(self._log_name,'Nodejs项目{}, 修改日志路径成功'.format(get.project_name))
2239 return public.returnMsg(True, "项目日志路径修改成功")
2240
2241 def for_split(self, logsplit, project):
2242 """日志切割方法调用

Callers

nothing calls this directly

Calls 10

get_project_findMethod · 0.95
stop_projectMethod · 0.95
start_projectMethod · 0.95
returnMsgMethod · 0.80
existsMethod · 0.45
dumpsMethod · 0.45
updateMethod · 0.45
whereMethod · 0.45
MMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected