Skip to content

SDRangel server with supervisor in Ubuntu

f4exb edited this page Sep 18, 2018 · 1 revision

Introduction

This was tested on a Pine RockPro64 using their Ubuntu server version (minimalist). It assumes user is f4exb, the server address is 192.168.1.34 and SDRangel is installed in /opt/install/sdrangel

Prerequisites:

sudo apt-get install python-pip python-setuptools
sudo pip install supervisor

This creates /usr/local/bin/supervisorctl and /usr/local/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/local/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)
        log_daemon_msg "Starting supervisor service" "supervisord"
        start-stop-daemon --start --background --no-close --oknodo --pidfile $PIDFILE --startas $DAEMON -- -n -c ${CONF_FILE} 
        status=$?
        echo $(pgrep -f $DAEMON) > $PIDFILE
        log_end_msg $status
        ;;
    stop)
        log_daemon_msg "Stopping supervisor service" "supervisord"
        start-stop-daemon --stop --oknodo --signal 15 --pidfile $PIDFILE
        status=$?
        log_end_msg $status
        ;;
    restart|force-reload)
        $0 stop && sleep 2 && $0 start
        ;;
    status)
        status_of_proc $DAEMON "supervisor service"
        ;;
    *)
        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 service supervisord defaults
sudo service supervisord enable
sudo update-rc.d supervisord defaults
sudo update-rc.d supervisord enable

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 /etc/supervisor/conf.d/sdrdaemonrx.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: Adjust -a, USER, HOME, PATH according to your network interface address, user and host

[program:sdrangelsrv]
command = /opt/install/sdrangel/bin/sdrangelsrv -a 192.168.1.34
process_name = sdrangelsrv
user = f4exb
stopsignal = INT
autostart = false
autorestart = false
environment =
    USER=f4exb,
    PATH="/home/f4exb/bin:/home/f4exb/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games",
    HOME="/home/f4exb"
redirect_stderr = true
stdout_logfile = /home/f4exb/log/sdrangelsrv.log
stdout_logfile_maxbytes = 10MB
stdout_logfile_backups = 3
loglevel = debug

Start the service and open web interface

sudo service supervisord start Open browser at http://192.168.1.34:9001

Clone this wiki locally