Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -380,46 +380,4 @@ async def delete_app(
content=response_formatter.buildErrorResponse(
f'Failed to delete app: {str(e)}'
),
)


@app_router.get('/apps/{app_id}/status')
@inject
async def get_app_status(
app_id: UUID,
response_formatter: ResponseFormatter = Depends(
Provide[CommonContainer.response_formatter]
),
app_service: AppService = Depends(Provide[ApplicationContainer.app_service]),
):
app = await app_service.get_app_by_id(app_id)

if not app:
logger.error(f'App with ID {app_id} not found')
return JSONResponse(
status_code=status.HTTP_404_NOT_FOUND,
content=response_formatter.buildErrorResponse('App not found'),
)

url = f'https://{app.app_name}-floware.apps.rootflo.ai/floware'

try:
response = requests.get(url + '/v1/health', timeout=10)

if response.status_code == 200:
await app_service.update_app(app_id, status=AppStatus.SUCCESS)
return JSONResponse(
status_code=status.HTTP_200_OK,
content=response_formatter.buildSuccessResponse({'status': 'success'}),
)
else:
return JSONResponse(
status_code=status.HTTP_200_OK,
content=response_formatter.buildSuccessResponse({'status': app.status}),
)
except requests.exceptions.RequestException as e:
logger.warning(f'Health check failed for app {app.app_name}: {str(e)}')
return JSONResponse(
status_code=status.HTTP_200_OK,
content=response_formatter.buildSuccessResponse({'status': app.status}),
)
)
Loading