[systemd-devel] I want to use an environmental variable for LimitNOFILE= in a service unit. Is it possible?

Lennart Poettering lennart at poettering.net
Thu Sep 3 10:38:59 PDT 2015


On Thu, 03.09.15 20:08, Eliezer Croitoru (eliezer at ngtech.co.il) wrote:

> I noticed it doesn't work.
> And well since I am building an RPM the only option I can think of is either
> use a custom startup script which will set the limits manually or define the
> service as a config file in the RPM.

Why that? Just set the default LimitNOFILE= in the unit file, and then
let the admin override it using the normal ways to override unit
files, either by adding drop-in .d/ files in /etc/systemd/system/ for
it, or by copying the unit file from /usr/lib/systemd/system/ to
/etc/systemd/system and editing it there. (Which is pretty much what
"systemctl edit" makes easy to do)

> Maybe you have some experience with overwriting the service files with RPMS,
> maybe there is some kind of practice use for this?

No. Unit files shipped in /usr/lib are not to be modified. People
should either override or extend them in /etc. And that's the same for
all unit files.

> The main issue is that if I hardcode it in the service file the RPM will
> replace it each and every time.
> If I will use it as a config file it will stay the same and it might be the
> better solution.
> Seeking after thought and ideas on the best way to implement it.

.d/ drop-ins are not overwritten like this...

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list