[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
Mon Sep 7 07:29:11 PDT 2015


Thanks For all the suggestions!!
Indeed I was unaware of all the options that systemd offers in terms of 
overriding the default service files.
Systemd makes it much simpler then sysVinit scripts replacement.

Eliezer

On 03/09/2015 20:10, Reindl Harald wrote:
>
>
> Am 03.09.2015 um 19:08 schrieb Eliezer Croitoru:
>> 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.
>
> RPM packages are suppused to ship systemdunits below
> /usr/lib/systemd/system and custom overrides are supposed to copy the
> unit to /etc/systemd/system/ with the same name
>
>> 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.
>
>
>
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel
>



More information about the systemd-devel mailing list