Re: rc script for a program - detach from tty?
Date: Wed, 21 Dec 2022 15:06:34 UTC
I'm sorry, I just woke up. daemon(8) will probably work for you. Not daemon(7). ~Paul On Wed, Dec 21, 2022 at 9:43 AM Odhiambo Washington <odhiambo@gmail.com> wrote: > 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 '^$|^.*#' ¯\_(ツ)_/¯ :-) > -- __________________ :(){ :|:& };: