The RadioVisServer is an implementation of a RadioVis server in Python. Only the Stomp mode is available.
For scalability, the server is connected to a RabbitMq server. It's possible to run multiples instances of the server (sharing one RabbitMq server), allowing more RadioVis client to be connected.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
- python 2.7
- docker 18.06.1+
- virtualenv 16.0.0+
- docker-compose 1.23.2+
virtualenv --python=$(which python2) venv
source venv/bin/activate
Install the required PIP dependencies:
pip install .
To deactivate the running environment:
deactivate
python server.py
python fallback.py
The configuration is stored inside config.py
. You can change it by setting environment variables corresponding to the config parameters.
Here is a list of the options you can configure through environment variables:
- RABBITMQ_HOST: Host of the RabbitMQ server. Defaults to
127.0.0.1
. - RABBITMQ_PORT: Port of the RabbitMQ server. Numeric. Defaults to
5672
. - RABBITMQ_USER: User to use when connection to the RabbitMQ server. Default to
guest
. - RABBITMQ_PASSWORD: Password of the chosen user. Defaults to
guest
. - RABBITMQ_VHOST: RabbitMQ vhost to use. Defaults to
/
. - RABBITMQ_DEBUG: If the connections with the RabbitMQ server should be in debug mode. Can be
True
|False
. Defaults toTrue
. - RABBITMQ_EXCHANGE: RabbitMQ exchange type that will be used by the vis server. Defaults to
amq.fanout
. - MONITORING_ENABLED: Switch to enable/disable the RabbitMQ monitoring plugin. Can be
True
|False
. Defaults toTrue
. - MONITORING_HOST: Host of the monitoring server for the RabbitMQ server. Defaults to
127.0.0.1
. - MONITORING_PORT: Port of the monitoring server for the RabbitMQ server. Defaults to
5672
. - MONITORING_USER: User to use when connection to the monitoring RabbitMQ server. Default to
guest
. - MONITORING_PASSWORD: Password of the chosen monitoring user. Defaults to
guest
. - MONITORING_VHOST: RabbitMQ monitoring vhost to use. Defaults to
/
. - MONITORING_DEBUG: If the connections with the RabbitMQ monitoring server should be in debug mode. Can be
True
|False
. Defaults toTrue
. - MONITORING_EXCHANGE: monitoring RabbitMQ exchange type. Defaults to
monitoring.buffer
. - MONITORING_QUEUE: monitoring RabbitMQ queue. Defaults to
radiovis
. - MONITORING_SERVER_ID: RabbitMQ node name. See the RabbitMQ docs.
- STOMP_IP: Accepted hosts for the stomp server. List of host comas separated. Defaults to
0.0.0.0
. - STOMP_PORT: Port where the stomp server will listen to. Numeric. Defaults to
61613
. - RADIODNS_API_URL: RadioDns VIS service url. Scheme:
http://<HOST>/<API_SECRET>/action/radiovis/api/<API_SECRET>/
. Please refer to the RadioDns manager repository for informations about the API_SECRET parameter. - MEMCACHED_HOST: Host of the memcached server. Defaults to
127.0.0.1
. - FB_CHANNEL_CACHE: Fallback channels cache time before being considered as stale. In Seconds. Defaults to
60
. - FB_FALLBACK_CHECK: Fallback interval check time. In Seconds. Defaults to
15
. - FB_FALLBACK_TIME: Fallback channel grace time. Time before a channel is considered dead. In Seconds. Defaults to
60
. - FB_LOGS_MAX_AGE: Fallback logs max age before being discarded. In Seconds. Defaults to
86400
(24h). - FB_LOGS_CLEANUP: Clean Fallaback logs every X seconds, X being this parameter. Defaults to
3600
(1h).
There is 3 mains parts: The RadioVis server, the fallback server and the test script
This part takes care of connection to RadioVis clients and forwarding of messages. This can be started using python server.py
. Multiple instances can be ran.
It's possible, for debugging, to run the server without a RabbitMQ server. In that case, tests will fail and the fallback server won't work.
The fallback server watch topics, and send the default image and text if there is no activity on a topics for a configurable amount of time. It also takes care of logging all messages (who are forwarded to the PlugIt server). It's connected directly to the RabbitMQ server.
Only one instance of the fallback server should be running at one time. The command to start it is python fallback.py
.
A testing unit is available to tests the RadioVis server and the fallback deamon. It's use node. All tests can simply be run using nosetests
. More details are available in the nose documentation. All tests are inside the file test.py
.
For testing, a special RadioDns class is used, faking call to the PlugIt API with testing values.
The fallback process take care of everything related to the watchdog feature and logging. 4 process are spawn.
This process retrieve the list of topics from the PlugIt server.
This process ensure we're connected to the RabbitMQ server.
This process check if a topics didn't receive a message for a long time and send the default media if needed.
This process takes care of cleaning logs
The Rabbitmq process take care of the communication with the RabbitMQ server. It connects to the main exchange, and consume message, broadcasting them to all listening process.
The RadioDns class takes care of communications to the PlugIt API server, allowing call e.g. for authentication, listing of topics, etc.
The Stomp class represent a Stomp connection. It takes care of communications with them, allowing login, subscriptions and messages management.
The server takes care of incoming Stomp connections, spawning a stomp server for each new connection and registering them to the RabbitMQ process. It also initializes everything at the startup.
The config is set inside
config.py. A base can be found in
config.py.dist`. Available options are :
The level of logs message to display.
Listening IP for the stomp server
Listening port for the stomp server
URL for API of the PlugIt server
Caching options, see http://beaker.readthedocs.org/en/latest/configuration.html#configuration
If set to true, don't use rabbitmq, but just send messages back! (For debugging)
The RabbitMQ host
The RabbitMQ port
The RabbitMQ user
The RabbitMQ password
The RabbitMQ vhost
If we connect to RabbitMQ using debug mode
The name of the RabbitMQ exchange
Seconds to cache the channel list
Persistant queue
The time when we check for timeouted channels. (Each FB_FALLBACK_CHECK seconds)
The time before a channel is dead
The base URL for default images (The PlugIt frontend)
The maximum number of seconds a log entry is kept
When logs are cleaned
A list of topics for testing
A list of CC=>GCC for testing
A GCC topic for testing
The CC equivalent topic for testing
The list of topics for the fallback server
FB_FALLBACK_CHECK for testing
FB_FALLBACK_TIME for testing
FB_QUEUE for testing
FB_LOGS_CLEANUP for testing
Default values for a channel for testing