Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 546386 - app-admin/ulogd - add systemd unit
Summary: app-admin/ulogd - add systemd unit
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Coacher
URL: http://bugzilla.netfilter.org/show_bu...
Whiteboard:
Keywords:
Depends on: 550330
Blocks: install-systemd-unit
  Show dependency tree
 
Reported: 2015-04-12 20:18 UTC by Jacek
Modified: 2015-09-09 20:21 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
ulogd.service (ulogd.service,356 bytes, text/plain)
2015-05-04 14:38 UTC, Coacher
Details
ulogd.service (ulogd.service,323 bytes, text/plain)
2015-05-25 03:26 UTC, Coacher
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jacek 2015-04-12 20:18:39 UTC
Hi,

Why there is not ulogd.service for systemd?
I'm not a developer but below paste first version.
Please do it better and put to portage. tnx.
j

[Unit]
Description=Userspace logging daemon for NFLOG
After=network.target

[Service]
ExecStart=/usr/sbin/ulogd -c /etc/ulogd.conf --uid ulogd --pidfile /run/ulogd.pid
PrivateTmp=true
TimeoutSec=10

[Install]
WantedBy=multi-user.target
Comment 1 Coacher 2015-04-17 19:22:32 UTC
(In reply to Jacek from comment #0)
> Hi,
> 
> Why there is not ulogd.service for systemd?

Hello.

Because it is not provided by upstream and I don't have systemd on any of my machines. I'll work on this issue. Thanks for the initial version.
Comment 2 Coacher 2015-05-04 14:38:45 UTC
Created attachment 402632 [details]
ulogd.service

Hello again.

Sorry for the delay on this one. Here is the updated systemd service file.

Jacek, can you try it on your machine, please? I've tested it inside a VM and it works fine, but I'd like to know if it works in a real world setup.

If somebody from @systemd team could give it a look and provide feedback, it would also be much appreciated.

@proxy-maint team do not yet commit this file to the tree, please. ulogd-2.0.5 was released recently and I'd like to have this file added together with the ebuild for 2.0.5, which I am already working on.

Thanks.
Comment 3 Jacek 2015-05-06 14:36:10 UTC
works ok for me.
tnx
Comment 4 Pacho Ramos gentoo-dev 2015-05-07 19:23:42 UTC
What is the reason for forcing it to fork with the --daemon option?
Comment 5 Mike Gilbert gentoo-dev 2015-05-07 19:43:48 UTC
To quote our wiki page:

> Use of Type=forking is appropriate if the exit of the parent process allows systemd to detect failures at startup, before other dependent units are started. Otherwise, use Type=simple if possible by running the daemon in the foreground.

Is the former case applicable here?
Comment 6 Coacher 2015-05-07 19:53:09 UTC
(In reply to Pacho Ramos from comment #4)
> What is the reason for forcing it to fork with the --daemon option?

Because otherwise ulogd stays in foreground. On the second thought it may be possible to avoid this and convert service to Type=simple and remove PIDFile option. I'll try that.
Comment 7 Coacher 2015-05-07 20:03:37 UTC
(In reply to Mike Gilbert from comment #5)
> To quote our wiki page:
> 
> > Use of Type=forking is appropriate if the exit of the parent process allows systemd to detect failures at startup, before other dependent units are started. Otherwise, use Type=simple if possible by running the daemon in the foreground.
> 
> Is the former case applicable here?

I don't know yet, but I'll try running ulogd in foreground.
Comment 8 Mike Gilbert gentoo-dev 2015-05-07 20:20:55 UTC
Let me restate my question: Does forking allow systemd to detect failures during startup? If so, forking is fine.
Comment 9 Jacek 2015-05-07 20:42:45 UTC
I've tested a bit more and your ulogd.service starts and stops ok like mine, but in case of any errors eg. bad config file, my scritps shows more details in journal. Probably because of forking.

j
Comment 10 Ian Delaney (RETIRED) gentoo-dev 2015-05-20 06:07:56 UTC
* app-admin/ulogd
     Available versions:  2.0.3 2.0.4 {dbi doc json mysql nfacct +nfct +nflog pcap postgres sqlite}

@proxy-maint team do not yet commit this file to the tree, please. ulogd-2.0.5 was released recently and I'd like to have this file added together with the ebuild for 2.0.5, which I am already working on.

Do you still wish to await the bumping to ulogd-2.0.5
Comment 11 Coacher 2015-05-21 00:05:38 UTC
(In reply to Ian Delaney from comment #10)
> Do you still wish to await the bumping to ulogd-2.0.5

Yes, please. ETA on this one and ulogd-2.0.5 introduction is 1-2 days. I just need to finish few remaining things at my primary job.

I am sorry for the delay.
Comment 12 Coacher 2015-05-24 08:44:24 UTC
(In reply to Coacher from comment #11)
> (In reply to Ian Delaney from comment #10)
> > Do you still wish to await the bumping to ulogd-2.0.5
> 
> Yes, please. ETA on this one and ulogd-2.0.5 introduction is 1-2 days. I
> just need to finish few remaining things at my primary job.

I've dealt with all the things I was supposed to do. I'll work on this bug today and upload ulogd-2.0.5 later in the evening.
Comment 13 Coacher 2015-05-25 03:26:02 UTC
Created attachment 403896 [details]
ulogd.service

Hello.

Here's an updated version of ulogd systemd unit file. Now it does not explicitly execute ulogd with --daemon option and unit type is "simple". Thanks to Pacho Ramos and Mike Gilbert for pointing this out.

(In reply to Mike Gilbert from comment #8)
> Let me restate my question: Does forking allow systemd to detect failures
> during startup? If so, forking is fine.

In this case forking is not necessary. systemd was able to detect startup failures in all of the several cases I've tried (missing config, misconfiguration, etc.) with this unit file.
Comment 14 Richard Freeman gentoo-dev 2015-05-25 10:07:10 UTC
(In reply to Coacher from comment #13)
> 
> (In reply to Mike Gilbert from comment #8)
> > Let me restate my question: Does forking allow systemd to detect failures
> > during startup? If so, forking is fine.
> 
> In this case forking is not necessary. systemd was able to detect startup
> failures in all of the several cases I've tried (missing config,
> misconfiguration, etc.) with this unit file.

Assuming the daemon is correctly written (fork happens after it is initialized and listening/etc), with forking you'd generally get the benefit that dependent processes would not start if there was a startup failure.  Without forking the failure would be detected, but dependent processes might have already started by then, since the unit is considered running as soon as its process is started.  With forking unit isn't considered running until it forks, and so a failure before then causes downstream units to fail as well (or at least not start - I forget if they are marked as failed).

I don't know if anything actually depends on ulogd though.
Comment 15 Ian Delaney (RETIRED) gentoo-dev 2015-05-29 08:32:47 UTC
Awaiting the release and appearance of ulogd-2.0.5
Comment 16 Coacher 2015-05-29 20:04:38 UTC
(In reply to Richard Freeman from comment #14)

I see. Thank you for the detailed explanation, Richard.

iptablesweb[0] is the only program I am aware of that specifically depends on ulogd. But it appears it was not updated since 2006 and is also missing from the portage tree.

Various log analyzers, e.g. logstash[1], can use the functionality provided by ulogd, but it is not a hard dependency for them.

Taking this into account I think we should leave ulogd systemd unit being `Type=simple` as it is now (in the attachments). Should the need arise we can always switch to `Type=forking`.


[0]: http://iptablesweb.sourceforge.net/
[1]: https://github.com/elastic/logstash
Comment 17 Coacher 2015-05-29 20:05:43 UTC
(In reply to Ian Delaney from comment #15)
> Awaiting the release and appearance of ulogd-2.0.5

Actually the bugreport is there already. See #550330.
Comment 18 Mike Gilbert gentoo-dev 2015-05-31 05:12:23 UTC
(In reply to Coacher from comment #16)

This is not just limited to units that have reverse dependencies.

For daemons that properly implement forking, Type=forking also allows "systemctl start" to detect failures immediately.

For example, take unbound, which reads a config file /etc/unbound/unbound.conf. If the config file is missing, it exits immediately with a non-zero status.

% sudo mv unbound.conf unbound.conf.bak
% sudo systemctl start unbound.service
Job for unbound.service failed because the control process exited with error code. See "systemctl status unbound.service" and "journalctl -xe" for details.

If unbound.service had Type=simple, systemctl start unbound.service would have succeeded with no immediate feedback for the sysadmin.
Comment 19 Ian Delaney (RETIRED) gentoo-dev 2015-06-03 09:50:02 UTC
*ulogd-2.0.4-r1 (30 May 2015)
*ulogd-2.0.5 (30 May 2015)

  30 May 2015; Ian Delaney <idella4@gentoo.org>
  +files/ulogd-2.0.5-remove-db-automagic.patch, +files/ulogd.init,
  +files/ulogd.logrotate, +files/ulogd.service, +ulogd-2.0.4-r1.ebuild,
  +ulogd-2.0.5.ebuild, -files/ulogd-2-ng.init, -files/ulogd-2.logrotate,
  -ulogd-2.0.3.ebuild, metadata.xml:
Comment 20 Coacher 2015-06-03 11:02:29 UTC
(In reply to Mike Gilbert from comment #18)

Thank you for the further explanation, Mike.

ulogd unit with `Type=forking` behaves the same way as you described in your comment and allows to detect failures immediately. I can see that this a useful feature. Right now ulogd unit in tree has `Type=simple`. I'll ask @proxy-maint team to update it.
Comment 21 Coacher 2015-06-03 11:05:31 UTC
Thanks to everybody who helped with this bug and especially to @systemd team.