Skip site navigation (1)Skip section navigation (2)
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&#39;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 &lt;<a href="mailto:odhiambo@gmail.com">odhiambo@gmail.com</a>&gt; 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&#39;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>&lt;CUT&gt;</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=&quot;YES&quot;<br><br>. /etc/rc.subr<br><br>name=&quot;qcluster&quot;<br>rcvar=&quot;${name}_enable&quot;<br>start_cmd=&quot;${name}_start&quot;<br>stop_cmd=&quot;${name}_stop&quot;<br>qcluster_logfile=&quot;/opt/mailman/mm/var/logs/${name}.log&quot;}<br><br>qcluster_start(){<br>    chdir /opt/mailman/mm/<br>    /usr/bin/su -m mailman -c &quot;/opt/mailman/mm/bin/django-admin qcluster --pythonpath /opt/mailman/mm/ --settings settings&quot; &amp;<br>}<br><br>qcluster_stop(){<br>        kill -9 `ps ax | grep &quot;django-admin qcluster&quot; | grep -v grep | awk &#39;{print $1}&#39;`<br>        echo &quot;.&quot;<br>}<br><br>load_rc_config ${name}<br>run_rc_command &quot;$1&quot;<br clear="all"><div>&lt;/CUT&gt;</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>&quot;<span style="font-size:12.8px">Oh, the cruft.</span><span style="font-size:12.8px">&quot;, </span><span style="font-size:12.8px">egrep -v &#39;^$|^.*#&#39; </span><span style="background-color:rgb(34,34,34);color:rgb(238,238,238);font-family:&quot;Lucida Console&quot;,Consolas,&quot;Courier New&quot;,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>:(){ :|:&amp; };:</div>
help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAFbbPuh%2BnR088NzPMuXBw8c26mG1OCMVYyXzzksFfLYNv8E5Rw>