trunk-recorder icon indicating copy to clipboard operation
trunk-recorder copied to clipboard

Startup trunk-recorder and radio-scanner on RPI boot

Open jeffbarclay opened this issue 10 months ago • 6 comments

trying to setup a @reboot script to start trunk-recorder in one tty session and also start radio-scanner in another tty session since both need to run simultaneously. here is the script I have but seems both try to run in the initial tty window and the rdio-scanner will only run after the trunk-recorder is killed.

 #!/bin/bash

date >> date.txt

setsid sh -c 'exec commmand <> /dev/tty2 >&0 2>&1'
/home/pi/trunk-build/trunk-recorder --config /home/pi/trunk-build/config.json

#openvt -c 2

setsid sh -c 'exec commmand <> /dev/tty3 >&0 2>&1'
/home/pi/trunk-build/rdio-scanner/rdio-scanner
 

jeffbarclay avatar Apr 10 '24 14:04 jeffbarclay

While I have not dug into the pipe transitions here, just based on the process order of operations, you might need to background the processes if the desire isn't to hold them open from this script.

hsoj avatar Apr 10 '24 22:04 hsoj

The problem is both scripts need to run at the same time. This configuration only fires the trunk-recorder and not the Rdio-scanner until after the trunk-recorder is killed

jeffbarclay avatar Apr 10 '24 22:04 jeffbarclay

tmux appears to be a way around this but I'm not sure how to script that?

jeffbarclay avatar Apr 10 '24 22:04 jeffbarclay

If you're asking about a headless system on an RPI, I'm assuming it's running systemd.

Have you set these up to not run behind systemd? How have you set these up to run initially?

Edit: Without digging into the system structure it self, you could probably slap a & at the end of the command calls in that script to accomplish what you're after; however, do note this might present additional issues depending on how the system is setup.

Example:

 #!/bin/bash

date >> date.txt

setsid sh -c 'exec commmand <> /dev/tty2 >&0 2>&1'
/home/pi/trunk-build/trunk-recorder --config /home/pi/trunk-build/config.json &

#openvt -c 2

setsid sh -c 'exec commmand <> /dev/tty3 >&0 2>&1'
/home/pi/trunk-build/rdio-scanner/rdio-scanner &

hsoj avatar Apr 10 '24 22:04 hsoj

Thanks this will work - I actually just got it working with tmux installed and scripted the tmux to startup with 2 sessions. On Apr 11, 2024, at 06:52, penguinzephyr @.***> wrote: Is there a reason you arent using the example systemd service? https://github.com/robotastic/trunk-recorder/blob/70698818065b24a494fc5488c82445609eab9ebc/examples/SETUP_SERVICE.md You could modify this example to start rdio-scanner as a separate service too. I personally prefer supervisor and it keeps both tr and rdio up for me happily. Example configuration. /etc/supervisor/conf.d/trunk-recorder.conf [program:trunk-recorder] user=ubuntu redirect_stderr=true stdout_logfile=/home/ubuntu/logs/trunk-recorder-supervisor.log stdout_logfile_maxbytes=32MB stdout_logfile_backups=10 directory=/home/ubuntu/ command=/bin/bash -c "/usr/local/bin/trunk-recorder -c /home/ubuntu/config.json" numprocs=1 /etc/supervisor/conf.d/rdio.conf [program:rdio] user=ubuntu redirect_stderr=true stdout_logfile=/home/ubuntu/logs/rdio.log stdout_logfile_maxbytes=32MB stdout_logfile_backups=10 directory=/home/ubuntu/ command=/home/ubuntu/rdio-scanner numprocs=1

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

jeffbarclay avatar Apr 11 '24 18:04 jeffbarclay

If it helps, just set Rdio-Scanner as a service. That way, Rdio-Scanner will always start on reboot and your can set up a @reboot crontab to start TrunkRecorder on every reboot. My @reboot crontab for my headless RPis point to a script containing the following text:

#!/bin/sh

sleep 1m

cd /home/truser/trunk-build
/home/truser/trunk-build/trunk-recorder --config={configuration file name}.json

-or- You can just start your tmux session and manually start TrunkRecorder then "detach" since Rdio-Scanner will already be running as a service.

Dewey3 avatar Apr 11 '24 22:04 Dewey3