Example DBBasic apps (an API, a blog and a microblog) and a template for new DBBasic modules.

0 downloads

dbbasic-examples/blog/healthcheck.py
Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/dbbasic-examples.git
HTTPS
https://gitstable.com/git/askrobots/dbbasic-examples.git
SSH
ssh://git@gitstable.com:2222/askrobots/dbbasic-examples.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

danq9 Add official module template for creating DBBasic packages 17cf88a 1 year, 1 month ago History
healthcheck.py · 854 bytes · 29 lines
1#!/usr/bin/env python3
2"""
3Lightweight health check script for Coolify
4Uses only Python standard library - no additional packages needed
5"""
6import sys
7import urllib.request
8import urllib.error
9import os
10
11def check_health():
12 # Get port from environment or use default
13 port = os.environ.get('PORT', '3000')
14 url = f'http://localhost:{port}/'
15
16 try:
17 # Check the homepage
18 response = urllib.request.urlopen(url, timeout=10)
19 if response.getcode() == 200:
20 print(f"Health check passed: {url} returned 200 OK")
21 sys.exit(0) # Healthy
22 print(f"Health check failed: {url} returned {response.getcode()}")
23 sys.exit(1) # Unhealthy
24 except Exception as e:
25 print(f"Health check failed: {url} - {e}")
26 sys.exit(1) # Unhealthy
27
28if __name__ == '__main__':
29 check_health()