From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.sysutils.supervision.general/2643 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Patrick Steinhardt Newsgroups: gmane.comp.sysutils.supervision.general Subject: [PATCH] svlogd: implement option to use alternate config file Date: Wed, 31 Jul 2019 20:00:32 +0200 Message-ID: Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="24507"; mail-complaints-to="usenet@blaine.gmane.org" Cc: Patrick Steinhardt To: supervision@list.skarnet.org Original-X-From: supervision-return-2233-gcsg-supervision=m.gmane.org@list.skarnet.org Wed Jul 31 20:00:45 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 1hssu3-0006EX-Ta for gcsg-supervision@m.gmane.org; Wed, 31 Jul 2019 20:00:44 +0200 Original-Received: (qmail 24713 invoked by uid 89); 31 Jul 2019 18:01:05 -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 24706 invoked from network); 31 Jul 2019 18:01:05 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=from :to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm1; bh=IYVcVbKhBdV+EymSvEtF92uCDW sSLZvZZvbLE1QbWSU=; b=Ak97K75T7InxXIXEyNQtG/T2/VlOOP9C35OXQ1IJoO 4pRdGM1Yx08ZPm7MgDm9n+sym0Ot2FbKXR891cofQmTzH8oH2ScITuehLyk7MpLb MosZBTHFT1TwiumJkOxyGlbyLZbIaDdtd22KqA0lymO1GwQvG2RS4wMJz/RIodtJ 7wJpkxqnNa0i/B/+r3pR/ws51BTGzNPOoNWsGxwUaVOZU2KPhjjs2NPxd8XA3TV/ 2iRDtm4s6HzABdhHExfqkmwWAd1oGIEA6ksO9qA8LrNW6tJ5PkuaeqG1MzG5jK1W y6uaXTpp9jLurWvoXxEQjfDINZQ0/yVZX4Tn3hd75zOg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=IYVcVbKhBdV+EymSv EtF92uCDWsSLZvZZvbLE1QbWSU=; b=YIV0nMb0PDkO149VsSGF0nBaF8yiEtjWh fmGD72iRNtBIQd/Jo6YfK/e2Z04jfbhNfG4dH9meMFGLMgIxIvXJSarzIz6icNav K/mK7sBDMPqM1I3Aw2zd6PqVVdyFhmDcf6CxJuSuBc52tTLHIC8gJruo0rYLd0bk wyxwpYjIF+1fypFo7KGFH1WbI/3zxlV8Z9ut0OO3SgMH4mzuhf0bpMOy2wylGl1q psxitZ7WKcTqdMHnS1oK0FVf7b1520/mWJi9EHfx5t7/FSt7zW69NqEPM+L+Aysm shRbcPauKPpOsAnMFB5VEEvfrq7F6/YnSZ55nYFCls//1IUnzuhbg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddrleehgdduudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgggfestdekredtre dttdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehpkhhs rdhimheqnecukfhppeejkedrheegrdeikedrvdegieenucfrrghrrghmpehmrghilhhfrh homhepphhssehpkhhsrdhimhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: X-Mailer: git-send-email 2.22.0 Xref: news.gmane.org gmane.comp.sysutils.supervision.general:2643 Archived-At: Right now, the svlogd daemon will always look up the log configuration in the target log directory itself. There's reasons though for having the configuration file located at a different place, e.g. to provide a global log configuration or to separate data from configuration. Introduce a new command line option, "-c", that takes as parameter an alternative log file. It can either be given a relative path, in which case svlogd will try to open it relative to the log directories, or an absolute path, where it will try to use a single configuration for each of the log directories. Add tests to verify that svlogd is correctly reading the alternative configuration file. Signed-off-by: Patrick Steinhardt --- Hi, I don't quite know whether this is the right place to send patches to, but runit's homepage didn't mention any way to contribute patches (or I didn't find it). Please feel free to redirect me if I've chosen the wrong place. Regards Patrick man/svlogd.8 | 15 ++++++++++++++- src/svlogd.c | 11 ++++++++--- src/svlogd.check | 10 ++++++++++ src/svlogd.dist | 5 +++++ 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/man/svlogd.8 b/man/svlogd.8 index 01b2324..5359d94 100644 --- a/man/svlogd.8 +++ b/man/svlogd.8 @@ -3,7 +3,8 @@ svlogd \- runit's service logging daemon .SH SYNOPSIS .B svlogd -[\-tttv] [\-r +[\-tttv] [\-c +.I file\fR] [\-r .I c\fR] [\-R .I xyz\fR] [\-l .I len\fR] [\-b @@ -377,6 +378,18 @@ the form YYYY-MM-DDTHH:MM:SS.xxxxx when writing to .I log or to standard error. .TP +.B \-c \fIfile +config file. +Use +.I file +as configuration instead of the default +.I log/config +path. +.I file +may either be absolute or relative, in which case it will be relative to the +.I log +directory. +.TP .B \-r \fIc replace. .I c diff --git a/src/svlogd.c b/src/svlogd.c index 90a3321..0109684 100644 --- a/src/svlogd.c +++ b/src/svlogd.c @@ -49,6 +49,7 @@ unsigned long linemax =1000; unsigned long buflen =1024; unsigned long linelen; +const char *config = "config"; const char *replace =""; char repl =0; @@ -437,13 +438,14 @@ unsigned int logdir_open(struct logdir *ld, const char *fn) { while (! stralloc_copys(&ld->processor, "")) pause_nomem(); /* read config */ - if ((i =openreadclose("config", &sa, 128)) == -1) + if ((i =openreadclose(config, &sa, 128)) == -1) warn2("unable to read config", ld->name); if (i != 0) { int len, c; unsigned long port; - if (verbose) strerr_warn4(INFO, "read: ", ld->name, "/config", 0); + if (verbose && *config != '/') strerr_warn5(INFO, "read: ", ld->name, "/", config, 0); + else if (verbose) strerr_warn3(INFO, "read: ", config, 0); for (i =0; i +1 < sa.len; ++i) { len =byte_chr(&sa.s[i], sa.len -i, '\n'); sa.s[len +i] =0; @@ -667,8 +669,11 @@ int main(int argc, const char **argv) { progname =*argv; - while ((opt =getopt(argc, argv, "R:r:l:b:tvV")) != opteof) { + while ((opt =getopt(argc, argv, "c:R:r:l:b:tvV")) != opteof) { switch(opt) { + case 'c': + config =optarg; + break; case 'R': replace =optarg; if (! repl) repl ='_'; diff --git a/src/svlogd.check b/src/svlogd.check index 7d926ef..e9584ee 100755 --- a/src/svlogd.check +++ b/src/svlogd.check @@ -24,4 +24,14 @@ echo t2 >"${ctmp}"/config echo $? cat "${ctmp}"/current +echo prelative-alternate >"${ctmp}"/alternate-config +echo foo |svlogd -c alternate-config "${ctmp}" +echo $? +cat "${ctmp}"/current + +echo pabsolute-alternate >>"${ctmp}"/alternate-config +echo foo |svlogd -c "${ctmp}"/alternate-config "${ctmp}" +echo $? +cat "${ctmp}"/current + rm -rf "${ctmp}" diff --git a/src/svlogd.dist b/src/svlogd.dist index b3329e6..8570230 100644 --- a/src/svlogd.dist +++ b/src/svlogd.dist @@ -19,3 +19,8 @@ baz :ar :az 0 +0 +relative-alternatefoo +0 +relative-alternatefoo +absolute-alternatefoo -- 2.22.0