修改日志文件地址 @author baozi <202-03-13> @param: get ( dict ): 请求: 包含项目名称和新的路径 @return
(self, get)
| 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 | """日志切割方法调用 |
nothing calls this directly
no test coverage detected