This service collects data from DailyHot API endpoints and stores it in a PostgreSQL database.
- Collects data from 56+ API endpoints
- Stores data in PostgreSQL database
- Runs every 30 minutes automatically
- Configurable via environment variables
- Dockerized for easy deployment
- Create a
docker-compose.ymlfile:
version: '3.8'
services:
api-collector:
build:
context: https://github.com/ryan32382/api-collector.git
dockerfile: Dockerfile
container_name: api-collector
restart: unless-stopped
environment:
- TZ=Asia/Shanghai
- API_BASE_URL=http://192.168.1.2:6688
- DB_HOST=192.168.1.2
- DB_PORT=9918
- DB_NAME=test_db
- DB_USER=noney
- DB_PASSWORD=jiegede3
volumes:
- ./logs:/app/logs
networks:
- default
networks:
default:
driver: bridge- Start the service:
docker-compose up -dAll configuration is done via environment variables:
API_BASE_URL: Base URL of the DailyHot APIDB_HOST: PostgreSQL database hostDB_PORT: PostgreSQL database portDB_NAME: PostgreSQL database nameDB_USER: PostgreSQL database usernameDB_PASSWORD: PostgreSQL database passwordTZ: Timezone (e.g., Asia/Shanghai)
The service creates a table api_collections with the following schema:
CREATE TABLE api_collections (
id SERIAL PRIMARY KEY,
platform VARCHAR(50) NOT NULL,
collection_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
data JSONB NOT NULL,
status INTEGER DEFAULT 200,
response_time INTEGER DEFAULT 0
);Logs are stored in the logs/collector.log file and also printed to the console.
MIT