Debug Backend Application
Debug Backend Application
This document provides detailed instructions on how to debug backend applications in the GMSSH platform, including health check interface implementation, service configuration, and debugging tips.
Overview
When debugging backend applications in the GMSSH platform, you need to ensure the service can properly respond to health check requests. The platform periodically checks service status to ensure application availability and stability.
Health Check Interface
Basic Requirements
For a service to be debugged properly, it must implement a ping interface for health checking. Whether it's an HTTP service or a Socket service, a health check endpoint needs to be provided.
- Check Frequency: Platform performs status check every 5 seconds
- Timeout: Usually 3-5 seconds
- Response Requirement: Return 200 status code to indicate service is normal
HTTP Service Health Check
Python (Flask) Example:
from flask import Flask, jsonify
import time
import os
app = Flask(__name__)
# Note: The health check ping interface must be a GET request
@app.route('/ping', methods=['GET'])
def ping():
""" Health check """
return jsonify(code=200, data="pong", msg="OK")
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8080, debug=True)Socket Service Health Check
For Socket services, a special health check mechanism needs to be implemented:
GMSSH SDK (Socket) Example:
# main.py
import asyncio
from simplejrpc.app import ServerApplication
from simplejrpc.response import jsonify
# Create application instance, specify socket file path
app = ServerApplication("app.socket")
@app.route(name="ping")
async def ping():
"""Echo interface with validation"""
return jsonify(code=200, data="pong", msg="Request successful")
@app.route(name="hello")
async def hello():
"""Simple greeting endpoint"""
return jsonify(code=200, data="Hello, GMSSH!", msg="Request successful")
if __name__ == "__main__":
asyncio.run(app.run())