From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 7256 invoked from network); 22 Jun 2023 17:44:28 -0000 Received: from alyss.skarnet.org (95.142.172.232) by inbox.vuxu.org with ESMTPUTF8; 22 Jun 2023 17:44:28 -0000 Received: (qmail 30768 invoked by uid 89); 22 Jun 2023 17:44:53 -0000 Mailing-List: contact supervision-help@list.skarnet.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Received: (qmail 30760 invoked from network); 22 Jun 2023 17:44:53 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687455865; x=1690047865; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:to:date:from:from:to:cc:subject :date:message-id:reply-to; bh=cHTKXkZ4e2GJ0Vcdp43cCde2hMKV5KLb1hWywfpq47E=; b=Sccp6MBwtYesTDlpjNfeymlgfro/KFyjvMLgzCGa4IH8tVvSMzfwpQf6SNCsXWUVnj f+0jrzYOswi2nym/edHenTOUgv9XXyPwTTwaTyY4XnCbWuUxIh/YAyHBkq6sZz9+IwuR AaA7g0m5vmRrUFfIG24PVLmUH9r0bga98oSmhUFuS1SEgCN1CQOhvDrrXYMnxyix1wTC H+27SzImJwDDz3wXRq2ZAbx7BEphU2IOPqtDoWJNhhY27thR6qkcmrn9dQfJDqzrFgCq kJgv2Vl+3BZrVQtk2GENV+xE0EHX0xmtSAoEHk60bcVfhC2vlR99OJ8CCO5ymve4ubGP ktGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687455865; x=1690047865; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:to:date:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=cHTKXkZ4e2GJ0Vcdp43cCde2hMKV5KLb1hWywfpq47E=; b=PUTEkXVvBkP62xclzLwy/S1XWc9fPzpTh9qLK+V7wQq8e5JIF5Y/Iidfh5Kwt9R9XL 2DisGpbH0D/aPqt5cc8iYgKUl1pforL/V8rbwGVK6kRdjivpWg1lE2yfhwsAhJoMLhun 4iaWbNqFi+Ti/k3uarTLI+89daeJjOGmMUF1AQ49LU0uRjYGrF1FuyfVSOrAZ7ZhAqz2 lj3mk27yEx/ysElEhnnzd9tsAkLLEoYcHcC8AcyVye/eI6HFU2P7wV0Da1ptflozP4xW px/SNkD/q0bRq9UQM5Agg6Eb5nnnoDTALgCdejkSkmscr4RT1EL34bhXE4srpVUNG3EG 5EjA== X-Gm-Message-State: AC+VfDzGWp1bZgeH3JQi4IXKpfTSeSpdvFEwaFm/mFt9M6jC/3E3A9zQ C49Uy68/dUU6hjFadrAwAmZ+X239eFQ= X-Google-Smtp-Source: ACHHUZ4mwqR5Geb9dHtM72g6uiCdCJIft/WroAgHQMQKF6GypzVfzrQIoJRi7BUf68D1pJrPapor0g== X-Received: by 2002:a0d:f384:0:b0:56d:1528:c56f with SMTP id c126-20020a0df384000000b0056d1528c56fmr18248528ywf.16.1687455864996; Thu, 22 Jun 2023 10:44:24 -0700 (PDT) From: "Casper Ti. Vector" X-Google-Original-From: "Casper Ti. Vector" Date: Fri, 23 Jun 2023 01:44:19 +0800 To: supervision@list.skarnet.org Subject: Re: A program that can get exactly the log of a supervised process? Message-ID: Mail-Followup-To: supervision@list.skarnet.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: On Sun, Oct 24, 2021 at 12:03:01AM +0800, Casper Ti. Vector wrote: > Any idea on how the log "teeing" may be done cleanly (and portably > if possible; something akin to `tail -f' seems unsuitable because of > potential log rotation), and perhaps any flaw or redundancy in the > design above? The recordio program is extremely enlightening here: * Instead of trying to communicate with the logger, our program can directly sit between the service and the logging pipe. (This also solves the lifespan issue cleanly, saving lots of code; the latter is apart from the lots of code to talk with the logger.) * When forking, we may let the parent (instead of the child) exec()s into the service, so our program does not need to forward signals. (But the loggrep subprocess from our program may die after the supervisor receives SIGCHLD from the service; therefore in order not to interfere with the next run of the service, we should ensure the loggrep program would exit on EOF and does not produce spurious outputs on its stdout.) The source code of the program, logtee (licence: CC0), is available at: It may be tested with (logtee is itself init-agnostic; writing an adapter to, for instance, s6, should be an easy exercise in the manipulation of argv): ------------------------------------------------------------------------ #!/bin/execlineb -P fdmove -c 3 1 logtee { fdmove 1 3 if { timeout 3 grep -q "bytes from" } echo } fdclose 3 fdmove -c 2 1 ping -i 10 example.com ------------------------------------------------------------------------ -- My current OpenPGP key: RSA4096/0x227E8CAAB7AA186C (expires: 2024.09.30) 7077 7781 B859 5166 AE07 0286 227E 8CAA B7AA 186C