From nobody Wed Dec 21 14:41:51 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 4Ncbkv3PfLz1H5Z1 for ; Wed, 21 Dec 2022 14:42:31 +0000 (UTC) (envelope-from odhiambo@gmail.com) Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) (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 4Ncbkt6ClKz4LR1 for ; Wed, 21 Dec 2022 14:42:30 +0000 (UTC) (envelope-from odhiambo@gmail.com) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20210112 header.b=M+eV+q67; spf=pass (mx1.freebsd.org: domain of odhiambo@gmail.com designates 2a00:1450:4864:20::12f as permitted sender) smtp.mailfrom=odhiambo@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-lf1-x12f.google.com with SMTP id o6so18920755lfi.5 for ; Wed, 21 Dec 2022 06:42:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=tig1Vr1G2RCwc1pXRndsZWdU7atlTE8dw15ZOxeVLKw=; b=M+eV+q67LDnHXuXiI2Gx4Y3hbOcq77twoA0xLXmyRt+YMQO540Olfe7DoZOSpLMLA7 rWH5uPVQyXEFm4DVlNlXE3bJ/ZqWhyEH+Wi+ryVTT0rp0MB/ZFCJAqeZfOXv0W4QMmdM iYFH3WNMniRUWWyf+abCuWChi8cgC7Hn9M8imsJ4t1Z3IwO20+/nWbBeQfvJquH33/FP FXRUX2RWxofpF33E1n2DDwvfO4U9awcZFqKWk6wlXCXVAO5WGnNhXmDkc7fndvao1/9V ssmAfg5nrKVN7BbkXlbA+z+OHxGD+kOO/7o1mdd4gYWVKbmhB8E2tMaAJgwv0w4w/QJb 1yYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=tig1Vr1G2RCwc1pXRndsZWdU7atlTE8dw15ZOxeVLKw=; b=V9cRbIw8KCIAoBOX9Hp3x9XbMYO6rTjF4vqKRAk7KbmijtknrAf2x8f2t/+hDzgR+B wHfpHZ/KZEo4uM9KOnY0pFOjtON4LfTskv/o83Gj5fsD6ocqD4SYn0yFvtCSKppzHacY jDy5JHxw1XKKUSV3peLeGuUi01cZS+igGTM6sO0AyeBppiu1cI+Mm9MUXDVIHIiY6nxo D4qN2r97uoA3j4V+KMC7dZmYcxobVCzb1zraBE9Tlhw/uwqHgsX1gFyPyQjZYBrKThGj Tb+bvtFNSJLKwd+HmbN8y+BWpdOxUclKoL2H7NKSwazpAgw87qQC2HTW0SxQXcum6uXc eExA== X-Gm-Message-State: AFqh2kpcRYvfSApwkjdGJhYJEHBL2EiXgzv+rzUtuYwM1LItNhOKWXX2 DMFsjz8KQTY7sttORFne+WwAACyiioKGooMiIEtFQcE7pCf81auL X-Google-Smtp-Source: AMrXdXuqeKxUJAHwMBaVUGTdhrjM+r3X8SNOKp2Odt/ANewJGlKPzGkd31vg1NRAX4VqzO/pQI+7n7xFZHuiUGOdi8M= X-Received: by 2002:a05:6512:228e:b0:4b6:f3af:b841 with SMTP id f14-20020a056512228e00b004b6f3afb841mr236586lfu.157.1671633748004; Wed, 21 Dec 2022 06:42:28 -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 From: Odhiambo Washington Date: Wed, 21 Dec 2022 17:41:51 +0300 Message-ID: Subject: rc script for a program - detach from tty? To: questions Content-Type: multipart/alternative; boundary="000000000000be92e905f0578f4c" X-Spamd-Result: default: False [-2.99 / 15.00]; SUBJECT_ENDS_QUESTION(1.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.99)[-0.991]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20210112]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; RCPT_COUNT_ONE(0.00)[1]; PREVIOUSLY_DELIVERED(0.00)[questions@freebsd.org]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::12f:from]; ARC_NA(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; MLMMJ_DEST(0.00)[questions@freebsd.org]; DKIM_TRACE(0.00)[gmail.com:+]; TO_DN_ALL(0.00)[]; MID_RHS_MATCH_FROMTLD(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; FROM_EQ_ENVFROM(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; RCVD_TLS_LAST(0.00)[]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; RCVD_COUNT_TWO(0.00)[2] X-Rspamd-Queue-Id: 4Ncbkt6ClKz4LR1 X-Spamd-Bar: -- X-ThisMailContainsUnwantedMimeParts: N --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. #! /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" --=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
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 backgroun= d, 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 al= so been able to run it with supervisor, but killing it still requires this = very brutal method :-)

I hope someone can help mod= ify this script to handle the start|stop in a much cleaner way.
<= br>

<CUT>

#! /bin/s= h
#
# $FreeBSD$
#

# PROVIDE: qclusterd
# REQUIRE: DAEMON=
# KEYWORD: shutdown

#
# Add the following lines to /etc/rc.co= nf to qcluster:
#
#qcluster_enable=3D"YES"

. /etc/rc= .subr

name=3D"qcluster"
rcvar=3D"${name}_enable&qu= ot;
start_cmd=3D"${name}_start"
stop_cmd=3D"${name}_st= op"
qcluster_logfile=3D"/opt/mailman/mm/var/logs/${name}.log&q= uot;}

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-ad= min qcluster --pythonpath /opt/mailman/mm/ --settings settings" &<= br>}

qcluster_stop(){
=C2=A0 =C2=A0 =C2=A0 =C2=A0 kill -9 `ps ax = | grep "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"
&= lt;/CUT>


--
<= div dir=3D"ltr">
Best regards,
Odhiambo WASHINGTON,
Nairobi,KE+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:-)
--000000000000be92e905f0578f4c--