Hi, I’m trying to set up a Raspberry Pi to run sonic pi headless for art installation setup. it’s interactive through network - but no terminal/laptop needed.
It works great if I have a terminal connected, but falls apart once all terminals are closed, or if try to run it without an SSH connection to begin with (just on startup)
I’ve been scratching my head at this for a few days now, would really appreciate any help!
Troubleshooting:
Running with nohup: nohup startup.sh & - starts sonic pi, plays, but stops after closing SSH terminal. Doesn’t play at all if done from crontab or systemd
nohup paplay test.wav & - this does work after closing ssh, so it’s not a general audio problem. Also aplay works the same.
I’m not sure exactly how nohup works - is it inherited by the commands started by the shell script?
For example, if you create ‘test.sh’ that runs paplay test.wav and run nohup test.sh & does that still work if you close the connection?
Also, is there anything in the Sonic Pi log files after it’s killed by closing the ssh connection? There might be something there that could give a clue as to what’s going on.
If you want to start something from a terminal/ssh connection and have it persist, have you looked at the screen command? It allows you to have a detached session persist after disconnection. You can also reconnect to that session if you ssh back in later.
#!/bin/bash
while true; do
paplay sound_test_guitar.wav
done
(ran with nohup test_play_forever.sh &)
After closing all terminals I left it on for a few minutes - it did keep going (unlike sonic-pi).
If it wasn’t inherited, presumable at least the first iteration should have been interrupted?
Any suspicious logs?:
Don’t think so.
I did look at logs, the server-errors log complained a bit ,something about jack_to_pulseaudio
But pretty sure it appeared before disconnecting. I’ll have to test again when I get a sec.
@SRSabuabu
I did see the screen command as well as tmux considered for this, but hadn’t had a chance to test them.
I assume you can also autostart them at boot, without an SSH session?
further research ideas
I came across the concepts of unix runlevels - used by init systems.
I have a hunch maybe closing all terminals changes the runlevel, which affects something in sonic-pi / xvfb / etc, but not paplay for instance?
Writing mainly as a reminder for myself to look into.