(id)
| 317 | |
| 318 | @app.route("/api/projects/<id>/stop", methods=["POST"]) |
| 319 | def stop_project(id): |
| 320 | project_path = os.path.join(PROJECTS_DIR, id) |
| 321 | assert os.path.exists(project_path), f"Project with id {id} does not exist" |
| 322 | |
| 323 | launcher_state, _ = get_launcher_state(project_path) |
| 324 | assert launcher_state |
| 325 | |
| 326 | assert launcher_state["state"] == "running", f"Project with id {id} is not running" |
| 327 | |
| 328 | # kill the process with the pid |
| 329 | try: |
| 330 | pid = launcher_state["pid"] |
| 331 | parent_pid = pid |
| 332 | parent = psutil.Process(parent_pid) |
| 333 | for child in parent.children(recursive=True): |
| 334 | child.terminate() |
| 335 | parent.terminate() |
| 336 | except: |
| 337 | pass |
| 338 | |
| 339 | set_launcher_state_data(project_path, {"state": "ready", "status_message" : "Ready", "port": None, "pid": None}) |
| 340 | return jsonify({"success": True}) |
| 341 | |
| 342 | |
| 343 | @app.route("/api/projects/<id>/delete", methods=["POST"]) |
no test coverage detected