From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.sysutils.supervision.general/2800 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Oliver Schad Newsgroups: gmane.comp.sysutils.supervision.general Subject: Re: The "Unix Philosophy 2020" document Date: Sat, 28 Dec 2019 00:54:07 +0100 Organization: Automatic Server AG Message-ID: <20191228005407.1bf2a764@dickeberta> References: <20190831130730.ki6ma7i5curucowe@caspervector> <20190901091157.bjtfhqq6d2rg75yo@caspervector> <20190927083816.tectynx7dzlfcvb7@caspervector> <20191012173743.drzlgnrw4hib6hh4@caspervector> <20191117062644.lt6wfmqwijqqhc5w@caspervector> <20191226175258.o2nsregew6tlqlbu@caspervector> <20191227112309.3fow6vynss2ifw4t@caspervector> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; boundary="Sig_/eT4jHmUL_f/BJdT3eSt_F=R"; protocol="application/pgp-signature" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="155569"; mail-complaints-to="usenet@blaine.gmane.org" Cc: supervision@list.skarnet.org Original-X-From: supervision-return-2389-gcsg-supervision=m.gmane.org@list.skarnet.org Sat Dec 28 00:54:19 2019 Return-path: Envelope-to: gcsg-supervision@m.gmane.org Original-Received: from alyss.skarnet.org ([95.142.172.232]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1ikzQw-000eKR-Ju for gcsg-supervision@m.gmane.org; Sat, 28 Dec 2019 00:54:18 +0100 Original-Received: (qmail 13250 invoked by uid 89); 27 Dec 2019 23:54:44 -0000 Mailing-List: contact supervision-help@list.skarnet.org; run by ezmlm Original-Sender: Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Original-Received: (qmail 13243 invoked from network); 27 Dec 2019 23:54:44 -0000 In-Reply-To: X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) Xref: news.gmane.org gmane.comp.sysutils.supervision.general:2800 Archived-At: --Sig_/eT4jHmUL_f/BJdT3eSt_F=R Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Fri, 27 Dec 2019 12:32:27 +0000 "Laurent Bercot" wrote: > As for cgroups-related chainloaders, I could probably write some in > s6-linux-utils, but wasn't the cgroups interface designed to make > sure those operations are trivial to implement as small scripts? I changed in the past sysv init scripts in exactly that way, that they created a cgroup first at start and killed all processes within that cgroup at the end. That where 5? lines of shell. You could provide that system wide, if you would offer some include mechanism (pre-run, post-stop) or within the run/finish scripts just include a shell library. In the first place it would be ok, to have the name of the service available as an identifier for the cgroup. A random name would only work if you persist it somewhere and have to manage the clean-up - I would prefer to use the directory's name of the run script. Is it available through a environment? Something like: ############## run ############## CGROUP_BASE_DIR=3D/sys/fs/cgroup/freezer cgroup=3D$run_dir mkdir $CGROUP_BASE_DIR/$cgroup echo $$ > $CGROUP_BASE_DIR/$cgroup/tasks # exec or include exec do_the_real_stuff ############## finish ############## CGROUP_BASE_DIR=3D/sys/fs/cgroup/freezer cgroup=3D$run_dir state_file=3D$CGROUP_BASE_DIR/$cgroup/freezer.state echo FROZEN > $state_file i=3D0 while ! grep FROZEN $state_file > /dev/null; do let i=3D$i+1 sleep 0.1 if [ $i -gt 100 ]; then break fi done kill -9 $(cat $CGROUP_BASE_DIR/$cgroup/tasks) ######################## Disclaimer: this has race-conditions by design. systemd has them as well. No, they don't say that of course. You can't read the tasks atomically and change their state to stopped, freeze or whatever. So they always could fork away. What you can do is repeat the killing/freezing/stopping until it succeeds (mabye never). Best Regards Oli --=20 Automatic-Server AG =E2=80=A2=E2=80=A2=E2=80=A2=E2=80=A2=E2=80=A2 Oliver Schad Gesch=C3=A4ftsf=C3=BChrer Turnerstrasse 2 9000 St. Gallen | Schweiz www.automatic-server.com | oliver.schad@automatic-server.com Tel: +41 71 511 31 11 | Mobile: +41 76 330 03 47 --Sig_/eT4jHmUL_f/BJdT3eSt_F=R Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAl4GmZ8ACgkQRilxUUuWlvA25gCglNqiXlPk9vnpPwnrXYg9cpsE YxAAn0snc9+Qk6ujYrltH9IWC6T6OkL2 =80DY -----END PGP SIGNATURE----- --Sig_/eT4jHmUL_f/BJdT3eSt_F=R--