Bug 221960 - databases/influxdb: Log to syslog patch
Summary: databases/influxdb: Log to syslog patch
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Eugene Grosbein
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-31 15:29 UTC by Sascha Holzleiter
Modified: 2017-09-14 11:19 UTC (History)
3 users (show)

See Also:
cheffo: maintainer-feedback+


Attachments
influx syslog patch (984 bytes, patch)
2017-08-31 15:29 UTC, Sascha Holzleiter
no flags Details | Diff
Influx logger patch (1.17 KB, patch)
2017-09-11 11:13 UTC, Sascha Holzleiter
no flags Details | Diff
Influx log patch (2.88 KB, patch)
2017-09-13 14:55 UTC, Sascha Holzleiter
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sascha Holzleiter 2017-08-31 15:29:24 UTC
Created attachment 185951 [details]
influx syslog patch

Hi,

the logfile redirection for influxdb doesn't seem to work, at least for me.
Starting influxdb in jail bounces the complete output to the console.

daemon(8) now has the options to redirect the childs stderr and stdout to a file or to syslog. I first thought about redirecting to a file but daemon(8) does not seem to implement a rotation scheme for it's output files. There is nothing that handles SIGHUP, SIGUSR1, ... So sending to syslog seems the most flexible way.

The following patch implements just that and adds an influxd_facility variable to change the default syslog facility (daemon).
Comment 1 cheffo 2017-09-07 19:03:38 UTC
Hi,

Is there some minimal FreeBSD version needed for this to work?
Comment 2 Sascha Holzleiter 2017-09-07 19:34:31 UTC
Just checked on https://www.freebsd.org/cgi/man.cgi and it seems these daemon options are rather new and only available since 11.1-RELEASE. I didn't realize that when i submitted the PR. 

I could redo the patch as a port option with an additional OS version check, if that helps.
Comment 3 Eugene Grosbein freebsd_committer 2017-09-08 13:30:15 UTC
(In reply to Sascha Holzleiter from comment #2)

Yes, please update your patch to work with all supported branches.
Comment 4 Sascha Holzleiter 2017-09-11 11:13:13 UTC
Created attachment 186255 [details]
Influx logger patch

This new patch uses plain old piping into logger to accomplish what the last patch did with the new daemon(8) options. This should work for all branches.

With this approach all users get logging to syslog out of the box. 

Although this is a change in the default install and not everyone is fond of syslog it beats having the logs flooded to console.
Comment 5 Eugene Grosbein freebsd_committer 2017-09-11 18:26:30 UTC
(In reply to Sascha Holzleiter from comment #4)

Why have you removed influxd_precmd() function needed to create INFLUXD_PIDDIR? FreeBSD supports systems starting with RAM-based non-persistent /var (diskless(8)) and such systems need this.

Also, this way you force usage of complex construct with extra run-time overhead for newer FreeBSD versions despite of the fact its daemon(8) has built-in syslog support. You can use following expression to differentiate FreeBSD version that have this support and use your previous approach for such systems:

.if ${OPSYS} == FreeBSD && ((OSVERSION >= 1100513 && OSVERSION < 1200000) || OSVERSION >= 1200015)

.endif

And use post-build target to conditionnaly modify ${WRKDIR}/influxd startup script.
Comment 6 Sascha Holzleiter 2017-09-13 14:55:54 UTC
Created attachment 186331 [details]
Influx log patch

The removal of the precmd function was an error that slipped through.

This patch can utilize both methods. For the OS versions with the new daemon(8) parameters it uses just daemon and for all others the logger pipe is used.

I verified the OSVERSION = 11.1 part as i only have 11.1 systems available.
Comment 7 Eugene Grosbein freebsd_committer 2017-09-13 23:17:07 UTC
Dear maintainer, are you OK with latest patch version?
Comment 8 commit-hook freebsd_committer 2017-09-14 11:18:36 UTC
A commit references this bug:

Author: eugen
Date: Thu Sep 14 11:17:53 UTC 2017
New revision: 449830
URL: https://svnweb.freebsd.org/changeset/ports/449830

Log:
  Redirect all output to syslog by means of daemon(8) having syslog support
  in recent FreeBSD versions and by means of piping it to logger(1)
  for previous FreeBSD versions: add influxd_facility and influxd_priority
  variables (defaults to daemon.info). Bump PORTREVISION.

  PR:		221960
  Submitted by:	Sascha Holzleiter
  Approved by:	cheffo (maintainer)

Changes:
  head/databases/influxdb/Makefile
  head/databases/influxdb/files/influxd.in
Comment 9 Eugene Grosbein freebsd_committer 2017-09-14 11:19:14 UTC
Committed, thanks!