in source/backend/src/transfer_sftp_backend.py [0:0]
def health_check():
response = jsonify({'message': "Health check executed."})
response.status_code = 200
fargate_ephemeral_space = psutil.disk_usage('/var/sftp-upload-scratch-space').free
logger.debug(f'TaskID: {fargate_task_id}(PID:{pid}) - health_check(): fargate task total space:: {fargate_ephemeral_space}')
Dimension = {
'Name': 'Fargate_Task',
'Value': fargate_task_arn
}
cw_args = {
'Namespace': 'ECS',
'MetricData': [
{
'MetricName': 'Fargate Task Ephemeral Storage',
'Dimensions': [Dimension],
'Value': fargate_ephemeral_space,
'Unit': 'Count',
'StorageResolution': 1
}
]
}
try:
cw_resp = cw.put_metric_data(**cw_args)
logger.debug(f': {fargate_task_id}(PID:{pid}) - health_check(): finished writing metric data: {cw_resp}')
return response
except Exception as e:
logger.error(f'TaskID: {fargate_task_id}(PID:{pid}) - health_check(): call to /health_check returned exception {e}')
return bad_request("Bad or Invalid Request", 500) # Internal Server Error