I have a bash script that calls liquidsoap like so
/bin/sh -c "echo \$\$ > \"${sdir}/pid/${sfile}.pid\" && exec liquidsoap \"${sdir}/liq/${sfile}.liq\" >/dev/null 2>&1 || rm \"${sdir}/pid/{$sfile}.pid\"" &
(For readability, it might look like this with variables filled in)
/bin/sh -c "echo \$\$ > \"/radio/pid/station.pid\" && exec liquidsoap \"/radio/liq/station.liq\" >/dev/null 2>&1 || rm \"/radio/pid/station.pid\"" &
In PHP, the script is called with
return shell_exec("{$this->streamBase}/scripts/{$this->streamName} start config {$stationConfig}");
My problem is, I just had to restart Apache, and when I did, it also killed the liquid soap instances. I would like to get it to run fully independent of Apache such that I could restart Apache and they would keep running.
I'm not sure how I can achieve that.
EDIT: I've tried changing
/bin/sh -c "echo \$\$ > \"${sdir}/pid/${sfile}.pid\" && exec liquidsoap \"${sdir}/liq/${sfile}.liq\" >/dev/null 2>&1 || rm \"${sdir}/pid/{$sfile}.pid\"" &
to
(/bin/sh -c "echo \$\$ > \"${sdir}/pid/${sfile}.pid\" && exec liquidsoap \"${sdir}/liq/${sfile}.liq\" >/dev/null 2>&1 || rm \"${sdir}/pid/{$sfile}.pid\"" & ) &
and
nohup /bin/sh -c "echo \$\$ > \"${sdir}/pid/${sfile}.pid\" && exec liquidsoap \"${sdir}/liq/${sfile}.liq\" >/dev/null 2>&1 || rm \"${sdir}/pid/{$sfile}.pid\"" &
Neither keep liquidsoap running if I restart (or stop/start) Apache. When Apache stops, so do those processes.