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> References: <CAAdA2WPF=1f9zFJFdTgNATRhJ741eHKtGwymsZsG5DGQNU5Xmw@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--000000000000ae019305f057e6e9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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=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 | aw= k > '{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 '^$|^.*#' =C2=AF\_(=E3=83=84)_/=C2=AF :-) > --=20 __________________ :(){ :|:& };: --000000000000ae019305f057e6e9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div>I'm sorry, I just woke up.</div><div><br></div><d= iv>daemon(8) will probably work for you.=C2=A0 Not daemon(7).</div><div><br= ></div><div>~Paul<br></div></div><br><div class=3D"gmail_quote"><div dir=3D= "ltr" class=3D"gmail_attr">On Wed, Dec 21, 2022 at 9:43 AM Odhiambo Washing= ton <<a href=3D"mailto:odhiambo@gmail.com">odhiambo@gmail.com</a>> wr= ote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px= 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><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 background, but mayb= e there is a better way than this?</div><div>Also when it starts, it launch= es several children and I have to kill it using this brutal way, which does= n't look quite dandy.</div><div><br></div><div>PS: I have also been abl= e 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 sc= ript to handle the start|stop in a much cleaner way.</div><div><br></div><d= iv><br></div><div><CUT></div><div><br></div><div>#! /bin/sh<br>#<br>#= $FreeBSD$<br>#<br><br># PROVIDE: qclusterd<br># REQUIRE: DAEMON<br># KEYWO= RD: shutdown<br><br>#<br># Add the following lines to /etc/rc.conf to qclus= ter:<br>#<br>#qcluster_enable=3D"YES"<br><br>. /etc/rc.subr<br><b= r>name=3D"qcluster"<br>rcvar=3D"${name}_enable"<br>star= t_cmd=3D"${name}_start"<br>stop_cmd=3D"${name}_stop"<br= >qcluster_logfile=3D"/opt/mailman/mm/var/logs/${name}.log"}<br><b= r>qcluster_start(){<br>=C2=A0 =C2=A0 chdir /opt/mailman/mm/<br>=C2=A0 =C2= =A0 /usr/bin/su -m mailman -c "/opt/mailman/mm/bin/django-admin qclust= er --pythonpath /opt/mailman/mm/ --settings settings" &<br>}<br><b= r>qcluster_stop(){<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 kill -9 `ps ax | grep &qu= ot;django-admin qcluster" | grep -v grep | awk '{print $1}'`<b= r>=C2=A0 =C2=A0 =C2=A0 =C2=A0 echo "."<br>}<br><br>load_rc_config= ${name}<br>run_rc_command "$1"<br clear=3D"all"><div></CUT>= ;</div><div><br></div><div><br></div>-- <br><div dir=3D"ltr"><div dir=3D"lt= r"><div dir=3D"ltr"><div>Best regards,<br>Odhiambo WASHINGTON,<br>Nairobi,K= E<br>+254 7 3200 0004/+254 7 2274 3223<br>"<span style=3D"font-size:12= .8px">Oh, the cruft.</span><span style=3D"font-size:12.8px">",=C2=A0</= span><span style=3D"font-size:12.8px">egrep -v '^$|^.*#'=C2=A0</spa= n><span style=3D"background-color:rgb(34,34,34);color:rgb(238,238,238);font= -family:"Lucida Console",Consolas,"Courier New",monospa= ce;font-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> </blockquote></div><br clear=3D"all"><br>-- <br><div dir=3D"ltr" class=3D"g= mail_signature">__________________<br><br>:(){ :|:& };:</div> --000000000000ae019305f057e6e9--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAFbbPuh%2BnR088NzPMuXBw8c26mG1OCMVYyXzzksFfLYNv8E5Rw>