foreman icon indicating copy to clipboard operation
foreman copied to clipboard

Fixes #709. Add Standard- and StandardError log configuration for SystemD

Open h0jeZvgoxFepBQ2C opened this issue 7 years ago • 7 comments

I've added options to configure the log entries for the systemd configuration. I overwrote the export defaults in the SystemD class, to keep the behaviour of writing to syslog the same as before (before, syslog was called explicit in the systemd files directly) - so it should not break the default behaviour from before.

I also added 2 tests which pass fine. Feel free to comment and merge, if everything is fine :)

Hope this PR is fine, it's my first one for this project :)

h0jeZvgoxFepBQ2C avatar Jul 26 '18 12:07 h0jeZvgoxFepBQ2C

Looks like the travis check is failing due to other reasons, not this PR as far as I understand it? @ddollar

h0jeZvgoxFepBQ2C avatar Aug 01 '18 09:08 h0jeZvgoxFepBQ2C

Do you know already when you have some time to give some feedback or merge it? @ddollar Thanks!

h0jeZvgoxFepBQ2C avatar Aug 07 '18 09:08 h0jeZvgoxFepBQ2C

Any update on this PR? As @lichtamberg said, the Travis build seems to have failed on something unrelated to the PR.

Can we perhaps rerun this PR on Travis?

ClikeX avatar Sep 12 '18 12:09 ClikeX

Actually this PR is broken, since the official systemd standard uses

# file:/ is missing
StandardOut=file:/path/to/file

I didn't have time to change this and since only newer versions of systemd allow file logging (see https://github.com/systemd/systemd/pull/7198) I cannot test it on my servers, since we have an older version installed. Will try to find some time to fix this and hope someone else can test it.

Also the CLI integration doesn't work completely, or at least I didn't manage it to work correctly - will also try to fix it.

h0jeZvgoxFepBQ2C avatar Sep 12 '18 13:09 h0jeZvgoxFepBQ2C

Ok, I've fixed the CLI integration & file descriptor, added another test & updated documentation. Would be nice if someone could test it, the Travis CI test fail is proably not related to my PR as others and me said already.

h0jeZvgoxFepBQ2C avatar Sep 12 '18 13:09 h0jeZvgoxFepBQ2C

I'm not sure we should add a new flag for error log files, as in other exports (ex supervisord) there's already the two files specified based on the log folder:

stdout_logfile=<%= log %>/<%= name %>-<%= num %>.log
stderr_logfile=<%= log %>/<%= name %>-<%= num %>.error.log

Source: https://github.com/ddollar/foreman/blob/master/data/export/supervisord/app.conf.erb

We should probably do the same for systemd? or add this option everywhere but that should be another MR IMO ;)

jarthod avatar Mar 02 '20 21:03 jarthod

For the record it looks like syslog (the only possible output at the moment) is being deprecated, I just saw this after upgrading to Ubuntu 22.04:

Standard output type syslog is obsolete, automatically updating to journal. Please update your unit file, and consider removing the setting altogether.

I have

> systemd --version
systemd 249 (249.11-0ubuntu3.6)

For the record, this is the customization I'm using now and it works fine with systemd v240+:

# custom part to use file logging instead of syslog
# "append" option only works with systemd v240+
# https://github.com/ddollar/foreman/pull/717
StandardOutput=append:<%= log %>/<%= name %>.log
StandardError=append:<%= log %>/<%= name %>.log

jarthod avatar Dec 07 '22 14:12 jarthod