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

Eliezer Croitoru eliezer at ngtech.co.il
Thu Sep 3 10:08:13 PDT 2015


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.

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

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.

Eliezer

On 03/09/2015 18:35, Lennart Poettering wrote:
> On Thu, 03.09.15 17:45, Eliezer Croitoru (eliezer at ngtech.co.il) wrote:
>
>> Hey,
>>
>> I am working on a service for squid caching service.
>> I have a need to define LimitNOFILE from an environmental variable instead
>> of only the service file.
>
> No this does not work. Environment expansion is only done for
> ExecStart= and related lines, and the environment is only determined
> right when the binary is invoked.
>
> Generally: configuration for units is supposed to be placed in units,
> Splitting that into environment files such as /etc/sysconfig/* makes
> things both more opaque for the admin and harder to process from
> applications reading unit files. Hence, your usecase is explicitly
> something we don't recommend.
>
> Lennart
>



More information about the systemd-devel mailing list