rc script for a program - detach from tty?

From: Odhiambo Washington <odhiambo_at_gmail.com>
Date: Wed, 21 Dec 2022 14:41:51 UTC
I am trying to find a way to run this program and make it detach from the
tty.
I can get it to start if I run it in the background, but maybe there is a
better way than this?
Also when it starts, it launches several children and I have to kill it
using this brutal way, which doesn't look quite dandy.

PS: I have also been able to run it with supervisor, but killing it still
requires this very brutal method :-)

I hope someone can help modify this script to handle the start|stop in a
much cleaner way.


<CUT>

#! /bin/sh
#
# $FreeBSD$
#

# PROVIDE: qclusterd
# REQUIRE: DAEMON
# KEYWORD: shutdown

#
# Add the following lines to /etc/rc.conf to qcluster:
#
#qcluster_enable="YES"

. /etc/rc.subr

name="qcluster"
rcvar="${name}_enable"
start_cmd="${name}_start"
stop_cmd="${name}_stop"
qcluster_logfile="/opt/mailman/mm/var/logs/${name}.log"}

qcluster_start(){
    chdir /opt/mailman/mm/
    /usr/bin/su -m mailman -c "/opt/mailman/mm/bin/django-admin qcluster
--pythonpath /opt/mailman/mm/ --settings settings" &
}

qcluster_stop(){
        kill -9 `ps ax | grep "django-admin qcluster" | grep -v grep | awk
'{print $1}'`
        echo "."
}

load_rc_config ${name}
run_rc_command "$1"
</CUT>


-- 
Best regards,
Odhiambo WASHINGTON,
Nairobi,KE
+254 7 3200 0004/+254 7 2274 3223
"Oh, the cruft.", egrep -v '^$|^.*#' ¯\_(ツ)_/¯ :-)