Date: Wed, 21 Dec 2022 10:06:34 -0500 From: Paul Procacci <pprocacci@gmail.com> To: Odhiambo Washington <odhiambo@gmail.com> Cc: questions <questions@freebsd.org> Subject: Re: rc script for a program - detach from tty? Message-ID: <CAFbbPuh%2BnR088NzPMuXBw8c26mG1OCMVYyXzzksFfLYNv8E5Rw@mail.gmail.com> In-Reply-To: <CAAdA2WPF=1f9zFJFdTgNATRhJ741eHKtGwymsZsG5DGQNU5Xmw@mail.gmail.com>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --]
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 '^$|^.*#' ¯\_(ツ)_/¯ :-)
>
--
__________________
:(){ :|:& };:
[-- Attachment #2 --]
<div dir="ltr"><div>I'm sorry, I just woke up.</div><div><br></div><div>daemon(8) will probably work for you. Not daemon(7).</div><div><br></div><div>~Paul<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Dec 21, 2022 at 9:43 AM Odhiambo Washington <<a href="mailto:odhiambo@gmail.com">odhiambo@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I am trying to find a way to run this program and make it detach from the tty.<div>I can get it to start if I run it in the background, but maybe there is a better way than this?</div><div>Also when it starts, it launches several children and I have to kill it using this brutal way, which doesn't look quite dandy.</div><div><br></div><div>PS: I have also been able to run it with supervisor, but killing it still requires this very brutal method :-)</div><div><br></div><div>I hope someone can help modify this script to handle the start|stop in a much cleaner way.</div><div><br></div><div><br></div><div><CUT></div><div><br></div><div>#! /bin/sh<br>#<br># $FreeBSD$<br>#<br><br># PROVIDE: qclusterd<br># REQUIRE: DAEMON<br># KEYWORD: shutdown<br><br>#<br># Add the following lines to /etc/rc.conf to qcluster:<br>#<br>#qcluster_enable="YES"<br><br>. /etc/rc.subr<br><br>name="qcluster"<br>rcvar="${name}_enable"<br>start_cmd="${name}_start"<br>stop_cmd="${name}_stop"<br>qcluster_logfile="/opt/mailman/mm/var/logs/${name}.log"}<br><br>qcluster_start(){<br> chdir /opt/mailman/mm/<br> /usr/bin/su -m mailman -c "/opt/mailman/mm/bin/django-admin qcluster --pythonpath /opt/mailman/mm/ --settings settings" &<br>}<br><br>qcluster_stop(){<br> kill -9 `ps ax | grep "django-admin qcluster" | grep -v grep | awk '{print $1}'`<br> echo "."<br>}<br><br>load_rc_config ${name}<br>run_rc_command "$1"<br clear="all"><div></CUT></div><div><br></div><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Best regards,<br>Odhiambo WASHINGTON,<br>Nairobi,KE<br>+254 7 3200 0004/+254 7 2274 3223<br>"<span style="font-size:12.8px">Oh, the cruft.</span><span style="font-size:12.8px">", </span><span style="font-size:12.8px">egrep -v '^$|^.*#' </span><span style="background-color:rgb(34,34,34);color:rgb(238,238,238);font-family:"Lucida Console",Consolas,"Courier New",monospace;font-size:13.6px">¯\_(ツ)_/¯</span><span style="font-size:12.8px"> :-)</span></div></div></div></div></div></div>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature">__________________<br><br>:(){ :|:& };:</div>
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAFbbPuh%2BnR088NzPMuXBw8c26mG1OCMVYyXzzksFfLYNv8E5Rw>
