RaspDAB/Automate operation with Supervisor

From Opendigitalradio
(Difference between revisions)
Jump to: navigation, search
m (Hb9egm moved page Automate operation with Supervisor to RaspDAB/Automate operation with Supervisor without leaving a redirect)

Revision as of 19:43, 6 July 2017


Installing Supervisor

It is time to make the operation automatic, such that when you power up the Raspberry Pi it will start the encoders and the multiplexer and deliver a multiplexed stream to the EasyDAB board.

To do so we use a software package called supervisor (extended information can be found at http://supervisord.org). We first need to install it with

  $ sudo apt-get install supervisor

This will probably also install python-meld3 as it needs that package to function correctly.

Supervisor configuration files folder

In this manual we will put the supervisor configuration files in a folder config in the user's home directory. If you want to put this elsewhere you need to make appropriate changes to the commands shown here. You can do this from a terminal window with

  $ mkdir config

or from the graphical file manager. In this folder we make 2 subfolders, supervisor and mux:

  $ chdir config
  $ mkdir supervisor
  $ mkdir mux

Again, you can also do this with the graphical filemanager.

Now we can make the configuration file for program srv1 (the name is arbitrary, you can use your own names to make identification of the stations easy). Do this for all stations that you want include in the ensemble.

The contents of the configuration file

Now let's have a look at the configuration file for the encoders. The following are examples:

  # DAB encoding using odr-audioenc
  command=/usr/local/bin/odr-audioenc -v [URL of audio stream] -C 200 -b 64 -r 48000 -c 2 -o tcp://localhost:59001 -D -L --audio-resampler=samplerate -L --src-converter-type=0 -p 58 -P /tmp/srv1-pad.fifo
  # PAD encoding using odr-padenc
  command=/usr/local/bin/odr-padenc -o /tmp/srv1-pad.fifo -p 58 -t /home/[UserID]/PAD/srv1/DLS/DLS1.txt -d /home/[UserID]/PAD/srv1/MOT

So you define a name for the program that supervisor uses to identify the process it governs. In this case 2 programs, the audio encoder and PAD encoder for station srv1.

You declare the command line as if you would invoke the program from a command line in a terminal window. Note that we don't use the more verbose reporting, as this would all be put in the log file, which is not necessary. The next 2 lines tell the supervisor program to start the program automatically, and also restart it when it stops. The number of startretries may seem high, but this is to ensure the audio encoder makes a sufficient number of retries when the connection to the stream server is temporarily lost. Then you can declare the priority, which in our case should all be the same - perhaps with the exception of the multiplexer. And you provide the location of the log files, in this case just one file in which both error and normal log messages are collected.

Make similar files for each station, and put these in the config/supervisor folder.

The configuration file for the multiplexer is similar:

  command=/usr/local/bin/odr-dabmux -e /home/[UserID]/config/mux/dab.mux

Note we give this priority 100 to delay the start of the multiplexer to give the processor time to start the NTP protocol and update the time.

Creating symbolic links

For each radio program that will be part of the multiplex ensemble you need to create a symbolic link into the /etc/supervisor/conf.d/ folder. This is where supervisor will look for the configuration files. Providing symbolic links will point the program to the files we just created, so supervisor will know the parameters for the audio and PAD encoders and the multiplexer.

Now we can make the symbolic links (assuming 'odr' is your username):

  $ sudo ln -s /home/odr/config/supervisor/srv1.conf /etc/supervisor/conf.d/srv1.conf

for the configuration file for program srv1. You should do this for all stations you want to include in the multiplex and the multiplex program configuration file itself.

Getting Supervisor to work

For every change you make to the configuration files you need to call supervisorctl to reread and update its configuration:

  $ sudo supervisorctl reread
  $ sudo supervisorctl update

This will start supervisord and install it as a deamon, so it will automatically start from now on and start/restart the programs. All services are launched from supervisor, you don't need to start them manually anymore.

To show status of all services :

  $ sudo supervisorctl status

To [stop|start|restart] a service :

  $ sudo supervisorctl [stop|start|restart] service-name

To apply change after change anything in /home/[UserID]/config/supervisor/ file you need to call supervisor to reread and update configuration.

If you simply type

   sudo supervisorctl

this will not revert to the command prompt, but you will be able to monitor the supervisor status and issue the commands directly.

Supervisor redirects all logs from the tools to files in /var/log/supervisor/ You may need to ensure yourself that this directory exists. The logs will get rotated according to the policy defined by your distribution. More details in the child logging section of the documentation. Please refer to the official supervisor documentation for more details.

If you have correctly installed all programs and configured them correctly you will now have a micro DAB transmitter, with the audio encoding, PAD encoding and multiplexer in a single Raspberry Pi and the modulator in the EasyDAB v2 board, that will automatically start to encode and multiplex and subsequently modulate and transmit the DAB ensemble as soon as you provide a supply voltage. It may take about a minute for the whole process to start, but once it does it will continue until you remove the supply voltage again.

Personal tools