Skip to content

SDRangel server with supervisor in OpenSUSE

f4exb edited this page Sep 18, 2018 · 8 revisions

Supervisor is a Python package that makes it very easy to manage processes using a simple web interface This was tested on a Raspberry Pi 3B under OpenSUSE LEAP 15.0

Assumes user is f4exb and server IP address is 192.168.1.38. Change it to your own.

Install supervisor

sudo zypper in python2-pip
sudo pip install supervisor

This creates /usr/bin/supervisorctl and /usr/bin/supervisord and is only the bare minimum.

Create the service

Create /etc/init.d/supervisord with this content:

#!/bin/sh
### BEGIN INIT INFO
# Provides:        supervisord
# Required-Start:  $network $syslog
# Required-Stop:   $network $syslog
# Default-Start:   2 3 4 5
# Default-Stop:    0 1 6
# Short-Description: Supervisor daemon
### END INIT INFO
# Do 'sudo systemctl daemon-reload' to implement and after each change to this file

. /lib/lsb/init-functions
DAEMON=/usr/bin/supervisord
PIDFILE=/var/run/supervisord.pid
CONF_FILE=/etc/supervisor/supervisord.conf
test -x $DAEMON || exit 5
test -f ${CONF_FILE} || exit 5

case $1 in
    start)
        echo -n "Starting supervisor service" "supervisord"
        /sbin/startproc $DAEMON -n -c ${CONF_FILE}
        rc_status -v
        ;;
    stop)
        echo -n "Stopping supervisor service" "supervisord"
        /sbin/killproc -TERM $DAEMON
        rc_status -v
        ;;
    restart|force-reload)
        $0 stop && sleep 2 && $0 start
        rc_status
        ;;
    status)
        /sbin/checkproc $DAEMON
        rc_status -v
        ;;
    *)
        echo "Usage: $0 {start|stop|restart|force-reload|status}"
        exit2
        ;;
esac

give it execution permission:

sudo chmod +x /etc/init.d/supervisord

Setup the service

sudo mkdir /var/log/supervisor
sudo systemctl enable supervisord

Configuration:

sudo mkdir -p /etc/supervisor/conf.d

Create /etc/supervisor/supervisord.conf with this content:

; supervisor config file

[unix_http_server]
file=/var/run/supervisor.sock   ; (the path to the socket file)
chmod=0700                       ; sockef file mode (default 0700)

[supervisord]
user=root
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
childlogdir=/var/log/supervisor            ; ('AUTO' child log dir, default $TEMP)
logfile_maxbytes = 10MB
logfile_backups = 3
loglevel = info

[inet_http_server]
port = *:9001
;username = admin
;password = admin

[supervisorctl]
serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL  for a unix socket

; the below section must remain in the config file for RPC
; (supervisorctl/web interface) to work, additional interfaces may be
; added by defining them in separate rpcinterface: sections
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

; The [include] section can just contain the "files" setting.  This
; setting can list multiple files (separated by whitespace or
; newlines).  It can also contain wildcards.  The filenames are
; interpreted as relative to this file.  Included files *cannot*
; include files themselves.

[include]
files = /etc/supervisor/conf.d/sdrangelsrv.conf

Config file to run sdrangel

Assumes SDRangel is compiled from source and installed in /opt/install/sdrangel

mkdir ~/log

Create /etc/supervisor/conf.d/sdrangelsrv.conf with this content:

/!\ Pay attention to environment. You need all variables for pulseaudio dependency. Adjust -a, HOSTNAME, USER, HOME, LOGNAME, PATH according to your network interface address, user and host

[program:sdrangelsrv]
command = /opt/install/sdrangel/bin/sdrangelsrv -a 192.168.1.38
process_name = sdrangelsrv
user = f4exb
stopsignal = INT
autostart = false
autorestart = false
environment =
    HOSTTYPE=aarch64,
    HOSTNAME=rpi3p01,
    AUDIODRIVER=pulseaudio,
    ALSA_CONFIG_PATH="/etc/alsa-pulse.conf",
    MACHTYPE="aarch64-suse-linux",
    QEMU_AUDIO_DRV=pa,
    USER=f4exb,
    HOME="/home/f4exb",
    OSTYPE=linux,
    XDG_DATA_DIRS="/usr/share",
    SHELL="/bin/bash",
    PYTHONSTARTUP="/etc/pythonstart",
    LOGNAME=f4exb,
    DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/1000/bus",
    XDG_RUNTIME_DIR="/run/user/1000",
    XDG_CONFIG_DIRS="/etc/xdg",
    PATH="/home/f4exb/bin:/usr/local/bin:/usr/bin:/bin",
    SDL_AUDIODRIVER=pulse,
    CPU=aarch64
redirect_stderr = true
stdout_logfile = /home/f4exb/log/sdrangelsrv.log
stdout_logfile_maxbytes = 10MB
stdout_logfile_backups = 3
loglevel = debug

Running

You can access supervisor interface at http:\\192.168.1.38:9001

Clone this wiki locally