fix launch issue
This commit is contained in:
@@ -841,4 +841,43 @@ def deploy_stack():
|
||||
return jsonify({'error': 'Request timed out while deploying stack. The operation may still be in progress.'}), 504
|
||||
except Exception as e:
|
||||
current_app.logger.error(f"Error deploying stack: {str(e)}")
|
||||
return jsonify({'error': str(e)}), 500
|
||||
|
||||
@launch_api.route('/save-instance', methods=['POST'])
|
||||
@csrf.exempt
|
||||
def save_instance():
|
||||
try:
|
||||
if not request.is_json:
|
||||
return jsonify({'error': 'Request must be JSON'}), 400
|
||||
|
||||
data = request.get_json()
|
||||
required_fields = ['name', 'port', 'domains', 'stack_id', 'stack_name', 'status', 'repository', 'branch']
|
||||
|
||||
if not all(field in data for field in required_fields):
|
||||
missing_fields = [field for field in required_fields if field not in data]
|
||||
return jsonify({'error': f'Missing required fields: {", ".join(missing_fields)}'}), 400
|
||||
|
||||
# Save instance data
|
||||
instance_data = {
|
||||
'name': data['name'],
|
||||
'port': data['port'],
|
||||
'domains': data['domains'],
|
||||
'stack_id': data['stack_id'],
|
||||
'stack_name': data['stack_name'],
|
||||
'status': data['status'],
|
||||
'repository': data['repository'],
|
||||
'branch': data['branch'],
|
||||
'created_at': datetime.utcnow().isoformat()
|
||||
}
|
||||
|
||||
# Save to database using KeyValueSettings
|
||||
KeyValueSettings.set_value(f'instance_{data["name"]}', instance_data)
|
||||
|
||||
return jsonify({
|
||||
'message': 'Instance data saved successfully',
|
||||
'data': instance_data
|
||||
})
|
||||
|
||||
except Exception as e:
|
||||
current_app.logger.error(f"Error saving instance data: {str(e)}")
|
||||
return jsonify({'error': str(e)}), 500
|
||||
Reference in New Issue
Block a user