Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 Dec 2022 17:41:51 +0300
From:      Odhiambo Washington <odhiambo@gmail.com>
To:        questions <questions@freebsd.org>
Subject:   rc script for a program - detach from tty?
Message-ID:  <CAAdA2WPF=1f9zFJFdTgNATRhJ741eHKtGwymsZsG5DGQNU5Xmw@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
--000000000000be92e905f0578f4c
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

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=3D"YES"

. /etc/rc.subr

name=3D"qcluster"
rcvar=3D"${name}_enable"
start_cmd=3D"${name}_start"
stop_cmd=3D"${name}_stop"
qcluster_logfile=3D"/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>


--=20
Best regards,
Odhiambo WASHINGTON,
Nairobi,KE
+254 7 3200 0004/+254 7 2274 3223
"Oh, the cruft.", egrep -v '^$|^.*#' =C2=AF\_(=E3=83=84)_/=C2=AF :-)

--000000000000be92e905f0578f4c
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"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 backgroun=
d, 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 al=
so 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 mod=
ify 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/s=
h<br>#<br># $FreeBSD$<br>#<br><br># PROVIDE: qclusterd<br># REQUIRE: DAEMON=
<br># KEYWORD: shutdown<br><br>#<br># Add the following lines to /etc/rc.co=
nf to qcluster:<br>#<br>#qcluster_enable=3D&quot;YES&quot;<br><br>. /etc/rc=
.subr<br><br>name=3D&quot;qcluster&quot;<br>rcvar=3D&quot;${name}_enable&qu=
ot;<br>start_cmd=3D&quot;${name}_start&quot;<br>stop_cmd=3D&quot;${name}_st=
op&quot;<br>qcluster_logfile=3D&quot;/opt/mailman/mm/var/logs/${name}.log&q=
uot;}<br><br>qcluster_start(){<br>=C2=A0 =C2=A0 chdir /opt/mailman/mm/<br>=
=C2=A0 =C2=A0 /usr/bin/su -m mailman -c &quot;/opt/mailman/mm/bin/django-ad=
min qcluster --pythonpath /opt/mailman/mm/ --settings settings&quot; &amp;<=
br>}<br><br>qcluster_stop(){<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 kill -9 `ps ax =
| grep &quot;django-admin qcluster&quot; | grep -v grep | awk &#39;{print $=
1}&#39;`<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 echo &quot;.&quot;<br>}<br><br>load=
_rc_config ${name}<br>run_rc_command &quot;$1&quot;<br clear=3D"all"><div>&=
lt;/CUT&gt;</div><div><br></div><div><br></div>-- <br><div dir=3D"ltr" clas=
s=3D"gmail_signature" data-smartmail=3D"gmail_signature"><div dir=3D"ltr"><=
div dir=3D"ltr"><div>Best regards,<br>Odhiambo WASHINGTON,<br>Nairobi,KE<br=
>+254 7 3200 0004/+254 7 2274 3223<br>&quot;<span style=3D"font-size:12.8px=
">Oh, the cruft.</span><span style=3D"font-size:12.8px">&quot;,=C2=A0</span=
><span style=3D"font-size:12.8px">egrep -v &#39;^$|^.*#&#39;=C2=A0</span><s=
pan style=3D"background-color:rgb(34,34,34);color:rgb(238,238,238);font-fam=
ily:&quot;Lucida Console&quot;,Consolas,&quot;Courier New&quot;,monospace;f=
ont-size:13.6px">=C2=AF\_(=E3=83=84)_/=C2=AF</span><span style=3D"font-size=
:12.8px">=C2=A0:-)</span></div></div></div></div></div></div>

--000000000000be92e905f0578f4c--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAAdA2WPF=1f9zFJFdTgNATRhJ741eHKtGwymsZsG5DGQNU5Xmw>