Skip to content

Repository files navigation

FOSS Public Alert Server

The FOSS Public Alert Server lets clients receive push notifications via UnifiedPush about emergency and weather alerts worldwide.

This is made possible thanks to OASIS' Common Alerting Protocol (CAP). CAP alerts are used for a wide variety of emergencies. From alerts about extreme weather to alerts about contaminated drinking water to pandemics.

Our server aggregates hundreds of CAP Feeds published by alerting authorities worldwide. When finished, this server can be used with clients like FOSS Warn and KDE's alert integration (still beta).

We have three main motivations. Firstly, we want to offer an easy-to-use alternative to proprietary emergency apps to allow privacy- and freedom-focused people to receive emergency alerts. Secondly, we want to enable other developers to implement clients for different devices like desktop PCs, smart speakers, and Linux smartphones, and last but not least, we want to make traveling easier. While traveling, no one wants to search for and install the local emergency app to receive emergency alerts in this country. With our solution, there is one app for the world.   This project aims to expand the existing and already used alerting infrastructure and is not a replacement for any part of it. Stay informed and safe!

a project in collaboration with KDE and the FOSS Warn Team

This project is still in development and not yet ready for production!

Funding

2024-10 until 2025-10

This project was funded through the NGI0 Core Fund, a fund established by NLnet with financial support from the European Commission's Next Generation Internet program, under the aegis of DG Communications Networks, Content and Technology under grant agreement No. 101092990.

  

Server setup

The server consists of three parts:

  • An off-the-shelf PostGIS database server.
  • The AlertHandler, which retrieves the alert sources and stores the alerts in the database Stores alerts in the database and provides endpoints for retrieving alerts
  • the SubscriptionHandler, with which you can register for an area to receive push notifications
  • A celery worker who calls up the alert-fetching at regular intervals

Getting started

Development version

Starting the development version of Django requires some preliminary work. We recommend using the Provided Docker Compose file for starting the required RabbitMQ and PostGIS services.

To get started with the project, install UV, a fast and performant Python package manager.

# clone or download the repository
git clone https://invent.kde.org/webapps/foss-public-alert-server.git

# change the directory
cd foss-public-alert-server/dev-compose

# this requires having Docker installed
docker compose up -d # this might require sudo depending on your installation

# for stopping the containers run
docker compose down

To execute the Django project, you first need to install some dependencies. The following Linux packages are required:

Fedora

  • libpq-devel
  • python3-devel
# install these packages with
sudo dnf install libpq-devel python3-devel

Debian/ubuntu

  • pg_config
  • python-dev
# install these packages with
sudo apt install pg_config python-dev

With these packages installed and RabbitMQ and PostGIS running, you can start Django with

# create directory for Prometheus metrics
mkdir -p /tmp/fpas-metrics
export PROMETHEUS_MULTIPROC_DIR=/tmp/fpas-metrics

export DJANGO_DEBUG=True # in case you want to activate the debug mode of Django

uv sync # only needed on first start or if the dependencies changed.
uv run manage.py collectstatic
uv run manage.py migrate
uv run manage.py runserver 8000

# at the first start, you must create a super user
uv run manage.py createsuperuser

# start celery worker for alert parsing
uv run celery -A foss_public_alert_server worker --loglevel=INFO -n alerts --concurrency 3

# start celery worker for sending push notifications
uv run celery -A foss_public_alert_server worker  --loglevel=INFO -Q push_notifications -n notifications --concurrency 1

# if you have Flower installed, you can start the Celery monitoring tool with
uv run celery -A foss_public_alert_server flower --port=5556
# You can now visit the flower under http://localhost:5556

# start celery beat
uv run celery -A foss_public_alert_server beat -l INFO --scheduler django_celery_beat.schedulers:DatabaseScheduler

Check out the official celery manual

This should install and build everything and should launch the Django application on http://localhost:8000

Development version with Docker quick start version

This repo contains a Docker Compose file that you can quickly start by:

# clone or download the repository
git clone https://invent.kde.org/webapps/foss-public-alert-server.git

# change the directory
cd foss-public-alert-server/compose 
# make sure the Docker daemon

# start the Docker container in the background
docker compose up -d # add --build to rebuild the container if needed

# wait until the container is up, then create a Django admin account
docker exec -it foss-public-alert-server-aggregator-1 uv run manage.py createsuperuser

# after that, you should be able to visit the admin page
# via http://localhost:8000/admin

Manual setup

PostGIS setup No special configuration is required, but there needs to be an empty database and, depending on your setup, a corresponding database user.

The aggregator service needs to be configured to find your PostGIS database. This can be done in or via environment variables.

  • POSTGRES_HOST: IP address or host name of the PostGIS server
  • POSTGRES_DATABASE: name of the PostGIS database
  • POSTGRES_USER: name of the user on the PostGIS database
  • POSTGRES_PASSWORD: password for connecting to the PostGIS database

The aggregator service is started as follows for local development:

Production deployment

The default config is for development only, and not safely configured for deployments! We will provide a production ready version in the future.

For a production deployment, you'll likely want to put this application behind an HTTP server. More information can be found in the Django deployment documentation.

About

Open source server that allows desktop applications to receive near real-time push notifications about emergency alerts worldwide.

Resources

Stars

24 stars

Watchers

4 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages