For reasons above my paygrade, I need to run multiple instances of a DB server on a physical host with a bare metal OS. I also need to limit the physical memory use of each instance.
I am using a template unit file to start up a few dozen instances. I am using EnvironmentFile
to specify different environment variables and command line arguments for each instance.
However, I also want to be able to specify a different memory limit for each instance. AFAICT, environment variable substitution does not work for resource limit options like MemoryHigh
.
I thought drop-in files would be the answer, but I couldn't a single example of using drop-in files with an instantiated service. Is there some way I can create one drop-in file for myservice@1
, a different drop-in file for myservice@2
, etc?
$ cat /etc/systemd/system/[email protected]
[Unit]
Description=Something
After=syslog.target network.target
[Service]
Type=forking
EnvironmentFile=/etc/myservice/myservice.%i.env
ExecStart=/usr/bin/myservice $OPTIONS_FROM_ENV
MemoryHigh=4G
[Install]
WantedBy=multi-user.target