@name 设置指定服务的状态
(self, get)
| 340 | |
| 341 | # 2024/7/15 下午8:56 设置指定服务的状态 |
| 342 | def set_project_status(self, get): |
| 343 | ''' |
| 344 | @name 设置指定服务的状态 |
| 345 | ''' |
| 346 | get.project_type = get.get("project_type", None) |
| 347 | if get.project_type is None: |
| 348 | return public.returnResult(False, 'project_type参数不能为空', code=5) |
| 349 | if not get.project_type in ("nodejs", "pm2", "general"): |
| 350 | return public.returnResult(False, |
| 351 | '项目类型:{} 不合法, 暂时支持是nodejs/pm2/general'.format(get.project_type), |
| 352 | code=5) |
| 353 | get.project_name = get.get("project_name", None) |
| 354 | if get.project_name is None: |
| 355 | return public.returnResult(False, 'project_name参数不能为空', code=5) |
| 356 | |
| 357 | if get.project_type == "pm2": |
| 358 | get.pm2_name = get.get("pm2_name", "") |
| 359 | if get.pm2_name == "": |
| 360 | return public.returnResult(False, 'pm2_name参数不能为空', code=5) |
| 361 | get.mode = "cluster_mode" |
| 362 | get.name = get.pm2_name |
| 363 | return self.set_pm2_status(get) |
| 364 | else: |
| 365 | get.status = get.get("status", None) |
| 366 | if get.status is None: |
| 367 | return public.returnResult(False, 'action参数不能为空', code=5) |
| 368 | if not get.status in ("restart", "stop", "start"): |
| 369 | return public.returnResult(False, 'action参数错误, 只支持restart/stop/start', code=5) |
| 370 | |
| 371 | self.set_project_model(get.project_type) |
| 372 | return getattr(self.projectModel, "{}_project".format(get.status))(get) |
| 373 | |
| 374 | # 2024/7/17 上午9:24 停止指定项目 |
| 375 | def stop_project(self, get): |
no test coverage detected