The issue is that I am not sure if I am replicating all the options specified in the original systemd script. I get a warning message saying that memory overcommit must be enabled. Could anyone help me determine if I did this incorrectly?
5841:M 06 Sep 2025 17:11:37.138 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommi t_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for th is to take effect. 5841:M 06 Sep 2025 17:11:37.138 * oO0OoO0OoO0Oo Valkey is starting oO0OoO0OoO0Oo 5841:M 06 Sep 2025 17:11:37.138 * Valkey version=8.1.3, bits=64, commit=d063dff5, modified=1, pid=5841, jus t started 5841:M 06 Sep 2025 17:11:37.138 * Configuration loaded 5841:M 06 Sep 2025 17:11:37.138 # You requested maxclients of 10000 requiring at least 10032 max file descr iptors. 5841:M 06 Sep 2025 17:11:37.138 # Server can't set maximum open files to 10032 because of OS error: Operati on not permitted. 5841:M 06 Sep 2025 17:11:37.138 # Current maximum open files is 4096. maxclients has been reduced to 4064 t o compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'. 5841:M 06 Sep 2025 17:11:37.138 * monotonic clock: POSIX clock_gettime 5841:M 06 Sep 2025 17:11:37.139 * Running mode=standalone, port=6379. 5841:M 06 Sep 2025 17:11:37.139 * Server initialized 5841:M 06 Sep 2025 17:11:37.139 * Loading RDB produced by Valkey version 8.1.3 5841:M 06 Sep 2025 17:11:37.139 * RDB age 16 seconds 5841:M 06 Sep 2025 17:11:37.139 * RDB memory usage when created 0.58 Mb 5841:M 06 Sep 2025 17:11:37.139 * Done loading RDB, keys loaded: 0, keys expired: 0. 5841:M 06 Sep 2025 17:11:37.139 * DB loaded from disk: 0.000 seconds 5841:M 06 Sep 2025 17:11:37.139 * Ready to accept connections tcp
Title: Re: How should I write a service for Valkey?
Post by: capezotte on 07 September 2025, 06:45:26
Your dinit service definition is mostly fine.
To avoid the warning about "Your requested maxclients...", add a rlimit-nofile directive to the dinit service (equivalent to systemd's LimitNOFILE). Read man 5 dinit-service for more details.
working-dir is not needed, systemd's RuntimeDirectory is actually translated by either relying on the service creating /run/valkey itself, or by creating a valkey-pre scripted service that calls mkdir.
Other than that, you've translated every option in the systemd service file with a direct equivalent whenever possible.
The CapabilityBoundingSet and PrivateWhatever/ProtectWhatever options could be translated with some effort by wrapping Valkey in a script that uses a sandboxing suite, but that's not really necessary, plus dedicated UIDs (run-as directives) provide a really good deal of isolation already.
The warning about memory overcommit, as the message explains, is avoided by running sysctl and making it permanent by adding that line to /etc/sysctl.conf. That's done outside the init system.
Some nitpicks:
Unlike systemd Requires + After, depends-ms and after don't need to be used together. Just pick one (AFAIK, most stock Artix services choose after)
Since you're not using a socket-listen directive, socket-uid and socket-gid aren't doing anything. And unless Valkey is one of the very few programs that support systemd-style socket activation without systemd, socket-listen won't do anything useful either.
Title: Re: How should I write a service for Valkey?
Post by: hys on 07 September 2025, 21:00:26
To avoid the warning about "Your requested maxclients...", add a rlimit-nofile directive to the dinit service (equivalent to systemd's LimitNOFILE). Read man 5 dinit-service for more details.
working-dir is not needed, systemd's RuntimeDirectory is actually translated by either relying on the service creating /run/valkey itself, or by creating a valkey-pre scripted service that calls mkdir.
Other than that, you've translated every option in the systemd service file with a direct equivalent whenever possible.
The CapabilityBoundingSet and PrivateWhatever/ProtectWhatever options could be translated with some effort by wrapping Valkey in a script that uses a sandboxing suite, but that's not really necessary, plus dedicated UIDs (run-as directives) provide a really good deal of isolation already.
The warning about memory overcommit, as the message explains, is avoided by running sysctl and making it permanent by adding that line to /etc/sysctl.conf. That's done outside the init system.
Some nitpicks:
Unlike systemd Requires + After, depends-ms and after don't need to be used together. Just pick one (AFAIK, most stock Artix services choose after)
Since you're not using a socket-listen directive, socket-uid and socket-gid aren't doing anything. And unless Valkey is one of the very few programs that support systemd-style socket activation without systemd, socket-listen won't do anything useful either.
Thank you for feedback, I modified the service according to your comments and it seems to be running correctly.