From nobody Wed Dec 21 15:06:34 2022 X-Original-To: questions@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NccGv3hwcz1H8pt for ; Wed, 21 Dec 2022 15:06:47 +0000 (UTC) (envelope-from pprocacci@gmail.com) Received: from mail-oa1-x34.google.com (mail-oa1-x34.google.com [IPv6:2001:4860:4864:20::34]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NccGv3Glkz4Pqr for ; Wed, 21 Dec 2022 15:06:47 +0000 (UTC) (envelope-from pprocacci@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: by mail-oa1-x34.google.com with SMTP id 586e51a60fabf-144bd860fdbso19531145fac.0 for ; Wed, 21 Dec 2022 07:06:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=VP9nqFDn0YF75YjS6MGA2jQNytJMJBijlOrPDF/5pJs=; b=WsnrLHXt2BvgTmjWlFsKWa/e/aEQYMZm2afvOxXC1h2ZxRD98AvINkKIQEEh3LW2jC FcpleSB7RVsK8dP90HrjzIjpQ/Uvh7k+wFsUGbbqArnKWa5EQfs0xzz52IJsebJUQ+uC +kfmoFLD3nrZNzTT3JsmETfX+IUrhQy25DCSPKdYFjNBBoMdCLTRinyEEm1ko9L5aRD4 mH/sCUcpSRgqh2JljoN9WH5vGNNA6RxuYjRCtX8JYpGEdb22bgjVNm89NBg02yBxxmMu kuw+fMdvAa/icYsC48vtF1gkdSdygBiAU0YnDtBTjB67m6BtpZFxp1tyw2EBS66B0LXY qnfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=VP9nqFDn0YF75YjS6MGA2jQNytJMJBijlOrPDF/5pJs=; b=Y3cQMQB0CSaUJH1ZYkZ4D++MF4FdM8EjzXVbVHeZgOEpcPhjyqba1i90m8YQPn+cRx //W6ObqAYMeVheLExfvcwLg+MIO09o2TnSB/XznW6BPAAlVOCIfu7nCHHomQ31AE5mL7 /VQnS17aIEpS9N2z5DkRPNdrG2E2N5K1PCgz5f5oRDPpG+uWoFmkIBVr/c2eM8Wr3k3s gHVHZpIumieUBwwbx7YS6I77LZBVdfwpup8e626SljCS/FWAlHCRuN9Q5V5h+fLdd00p PGFyaQr/7ZSl7yoX/bVxSviwJpAr4N1Le1IsISwO1nZDaZtNCC79XQpf3ckheNDqK12l dWEg== X-Gm-Message-State: AFqh2kpF5l16GnWiN/lHYBTZ9D4SkwZcQQWcOuz0Y448fTTN4fXlvO6H 8X1IPSu3xvlf8vKKnc5It88y2RAUXjXbxWWdFmTz5xI= X-Google-Smtp-Source: AMrXdXtlEoYnWRXo0vZwL1pqOa+FPAN+R2iXtf4M0sjbN50ShJVKDq2EX4gvRvQxjoHwliz99JCkDdRUA3AHLLcunnA= X-Received: by 2002:a05:6871:4194:b0:144:6067:de3e with SMTP id lc20-20020a056871419400b001446067de3emr102624oab.148.1671635206536; Wed, 21 Dec 2022 07:06:46 -0800 (PST) List-Id: User questions List-Archive: https://lists.freebsd.org/archives/freebsd-questions List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org MIME-Version: 1.0 References: In-Reply-To: From: Paul Procacci Date: Wed, 21 Dec 2022 10:06:34 -0500 Message-ID: Subject: Re: rc script for a program - detach from tty? To: Odhiambo Washington Cc: questions Content-Type: multipart/alternative; boundary="000000000000ae019305f057e6e9" X-Rspamd-Queue-Id: 4NccGv3Glkz4Pqr X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:15169, ipnet:2001:4860:4864::/48, country:US] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N --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 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. > > > > > #! /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" > > > > -- > 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
I'm sorry, I just woke up.

daemon(8) will probably work for you.=C2=A0 Not daemon(7).
~Paul

On Wed, Dec 21, 2022 at 9:43 AM Odhiambo Washing= ton <odhiambo@gmail.com> wr= ote:
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 mayb= e there is a better way than this?
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.

PS: I have also been abl= e to run it with supervisor, but killing it still requires this very brutal= method :-)

I hope someone can help modify this sc= ript to handle the start|stop in a much cleaner way.


<CUT>

#! /bin/sh
#
#= $FreeBSD$
#

# PROVIDE: qclusterd
# REQUIRE: DAEMON
# KEYWO= RD: shutdown

#
# Add the following lines to /etc/rc.conf to qclus= ter:
#
#qcluster_enable=3D"YES"

. /etc/rc.subr
name=3D"qcluster"
rcvar=3D"${name}_enable"
star= t_cmd=3D"${name}_start"
stop_cmd=3D"${name}_stop"qcluster_logfile=3D"/opt/mailman/mm/var/logs/${name}.log"}
qcluster_start(){
=C2=A0 =C2=A0 chdir /opt/mailman/mm/
=C2=A0 =C2= =A0 /usr/bin/su -m mailman -c "/opt/mailman/mm/bin/django-admin qclust= er --pythonpath /opt/mailman/mm/ --settings settings" &
}
qcluster_stop(){
=C2=A0 =C2=A0 =C2=A0 =C2=A0 kill -9 `ps ax | grep &qu= ot;django-admin qcluster" | grep -v grep | awk '{print $1}'`=C2=A0 =C2=A0 =C2=A0 =C2=A0 echo "."
}

load_rc_config= ${name}
run_rc_command "$1"
</CUT>= ;


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


--
__________________

:(){ :|:& };:
--000000000000ae019305f057e6e9--