Merge pull request #32 from tcivie/30-error-with-exporter
Docker error with exporter
This commit is contained in:
commit
fb034feee1
6
.env
6
.env
|
@ -8,10 +8,10 @@ PROMETHEUS_COLLECTOR_PORT=9464
|
|||
PROMETHEUS_JOB=example
|
||||
|
||||
# MQTT connection details
|
||||
MQTT_HOST=
|
||||
MQTT_HOST=mqtt.meshtastic.org
|
||||
MQTT_PORT=1883
|
||||
MQTT_USERNAME=
|
||||
MQTT_PASSWORD=
|
||||
MQTT_USERNAME=meshdev
|
||||
MQTT_PASSWORD=large4cats
|
||||
MQTT_KEEPALIVE=60
|
||||
MQTT_TOPIC='msh/israel/#'
|
||||
MQTT_IS_TLS=false
|
||||
|
|
68
.github/workflows/main.yml
vendored
Normal file
68
.github/workflows/main.yml
vendored
Normal file
|
@ -0,0 +1,68 @@
|
|||
name: Meshtastic Metrics Exporter Health Check
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
check-containers:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Start Docker Compose
|
||||
run: docker-compose up -d
|
||||
|
||||
- name: Wait for containers to start
|
||||
run: sleep 60 # 1 Minute
|
||||
|
||||
- name: Check container statuses and logs
|
||||
run: |
|
||||
services=("prometheus" "grafana" "exporter" "postgres")
|
||||
|
||||
for service in "${services[@]}"
|
||||
do
|
||||
container_id=$(docker-compose ps -q $service)
|
||||
|
||||
if [ -z "$container_id" ]; then
|
||||
echo "Error: Container for $service not found"
|
||||
docker-compose logs $service
|
||||
exit 1
|
||||
fi
|
||||
|
||||
status=$(docker inspect --format='{{.State.Status}}' $container_id)
|
||||
restarts=$(docker inspect --format='{{.RestartCount}}' $container_id)
|
||||
|
||||
if [ "$status" != "running" ]; then
|
||||
echo "Error: Container $service ($container_id) is not running. Current status: $status"
|
||||
echo "Last logs for $service:"
|
||||
docker-compose logs --tail=50 $service
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$restarts" -gt 0 ]; then
|
||||
echo "Error: Container $service ($container_id) has restarted $restarts times"
|
||||
echo "Last logs for $service:"
|
||||
docker-compose logs --tail=50 $service
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Container $service is running properly and has not restarted."
|
||||
done
|
||||
|
||||
- name: Check exposed ports
|
||||
run: |
|
||||
expected_ports=("9090" "3000")
|
||||
for port in "${expected_ports[@]}"
|
||||
do
|
||||
if ! netstat -tuln | grep -q ":$port "; then
|
||||
echo "Error: Port $port is not exposed"
|
||||
exit 1
|
||||
fi
|
||||
echo "Port $port is correctly exposed"
|
||||
done
|
||||
|
||||
- name: Clean up
|
||||
if: always()
|
||||
run: docker-compose down -v
|
|
@ -8,4 +8,5 @@ RUN pip3 install -r requirements.txt
|
|||
|
||||
COPY ../../exporter exporter
|
||||
COPY ../../main.py .
|
||||
COPY ../../constants.py .
|
||||
CMD ["python3", "-u", "main.py"]
|
Loading…
Reference in a new issue