地震预警服务,通过WebSocket获取地震信息并通知关注地区
873
一个基于WebSocket的综合预警服务,可以实时获取地震、气象和海啸等预警信息,并在关注条件满足时发送通知。
A comprehensive alert service based on WebSocket that can real-time obtain earthquake, meteorological, tsunami and other alert information, and send notifications when attention conditions are met.
npm install
config.yaml file to set the message types, sources, and conditions you want to follow:# Watch area list (compatible with old configuration)
watch_areas:
"四川": 4.0 # Sichuan
"云南": 4.0 # Yunnan
# Message type configuration
message_types:
enabled:
- "earthquake" # Earthquake messages
- "weatheralarm" # Weather alarm
- "tsunami" # Tsunami alert
# Source management configuration
# Can configure attention conditions for each data source individually
npm start
docker build -t earthquake-alert .
docker run -d --name earthquake-alert -v ./config.yaml:/app/config.yaml -v ./earthquake_log.txt:/app/earthquake_log.txt -v ./sent_messages.json:/app/sent_messages.json --restart always earthquake-alert
docker logs -f earthquake-alert
Ensure Docker Compose is installed
Start service
docker-compose up -d
docker-compose logs -f
docker-compose down
The configuration file config.yaml contains the following main configuration items:
websocket_url: "wss://ws.fanstudio.tech/all"
Format: City Name: Minimum Magnitude
watch_areas:
"四川": 4.0 # Pay attention to earthquakes above 4.0 in Sichuan area
"云南": 4.0 # Pay attention to earthquakes above 4.0 in Yunnan area
message_types:
# Enabled message types
enabled:
- "earthquake" # Earthquake messages
- "weatheralarm" # Weather alarm
- "tsunami" # Tsunami alert
# More types can be added as needed
sources:
# China Meteorological Administration weather alarm
weatheralarm:
enabled: true
type: "weatheralarm"
# Weather alarm configuration
weatheralarm:
# Focus alert levels: Red, Orange, Yellow, Blue
levels: ["红色", "橙色", "黄色"]
# Focus alert types: Strong wind, heavy rain, high temperature, etc.
alert_types: ["大风", "暴雨", "高温", "寒潮"]
# Focus areas
areas: ["四川", "云南", "重庆"] # Sichuan, Yunnan, Chongqing
# Ministry of Natural Resources tsunami alert
tsunami:
enabled: true
type: "tsunami"
# Tsunami alert configuration
tsunami:
# Focus alert levels
levels: ["红色", "橙色", "黄色", "蓝色", "解除"]
# Focus areas
areas: ["福建", "广东", "海南", "台湾"] # Fujian, Guangdong, Hainan, Taiwan
# China Earthquake Network Center earthquake information
cenc:
enabled: true
type: "earthquake"
# Earthquake configuration
earthquake:
# Minimum magnitude to focus on
min_magnitude: 3.5
# Focus areas
areas: ["四川", "云南", "重庆"] # Sichuan, Yunnan, Chongqing
notification:
# Whether to enable desktop notification
enable_desktop: true
# Whether to log to file
enable_log: true
# Log file path
log_file: "earthquake_log.txt"
# Whether to display notifications in console
enable_console: true
# Bark notification configuration
enable_bark: true
# Bark server address
bark_url: "https://api.day.app"
# Bark device key
bark_key: "your-bark-device-key"
# Log file control configuration
log_max_size: 10 # Maximum log file size, unit: MB
log_max_days: 30 # Maximum log file retention days
The service automatically creates a sent_messages.json file to store unique IDs of sent messages, avoiding:
sent_messages.json file to reset recordsconfig.yamlThis service connects to wss://ws.fanstudio.tech/all via WebSocket to obtain the following types of alert information:
MIT License
Content type
Image
Digest
sha256:1e7f30d67…
Size
48.2 MB
Last updated
5 months ago
docker pull quewen08/earthquake-alert