@name 自动启动所有项目 @author hwliang<2021-08-09> @return bool
(self)
| 2177 | return True |
| 2178 | |
| 2179 | def auto_run(self): |
| 2180 | ''' |
| 2181 | @name 自动启动所有项目 |
| 2182 | @author hwliang<2021-08-09> |
| 2183 | @return bool |
| 2184 | ''' |
| 2185 | project_list = public.M('sites').where('project_type=?',('Node',)).field('name,path,project_config').select() |
| 2186 | get= public.dict_obj() |
| 2187 | success_count = 0 |
| 2188 | error_count = 0 |
| 2189 | for project_find in project_list: |
| 2190 | try: |
| 2191 | project_config = json.loads(project_find['project_config']) |
| 2192 | if project_config['is_power_on'] in [0,False,'0',None]: continue |
| 2193 | project_name = project_find['name'] |
| 2194 | project_state = self.get_project_run_state(project_name=project_name) |
| 2195 | if not project_state: |
| 2196 | get.project_name = project_name |
| 2197 | result = self.start_project(get) |
| 2198 | if not result['status']: |
| 2199 | error_count += 1 |
| 2200 | error_msg = '自动启动Nodej项目['+project_name+']失败!' |
| 2201 | public.WriteLog(self._log_name, error_msg) |
| 2202 | else: |
| 2203 | success_count += 1 |
| 2204 | success_msg = '自动启动Nodej项目['+project_name+']成功!' |
| 2205 | public.WriteLog(self._log_name, success_msg) |
| 2206 | except: |
| 2207 | error_count += 1 |
| 2208 | if (success_count + error_count) < 1: return False |
| 2209 | dene_msg = '共需要启动{}个Nodejs项目,成功{}个,失败{}个'.format(success_count + error_count,success_count,error_count) |
| 2210 | public.WriteLog(self._log_name, dene_msg) |
| 2211 | return True |
| 2212 | |
| 2213 | def change_log_path(self, get): |
| 2214 | """"修改日志文件地址 |
nothing calls this directly
no test coverage detected