Merge pull request #33372 from Mic92/memcache
nixos/memcached: make unix sockets usuable
This commit is contained in:
commit
f29ecd56c1
|
@ -131,6 +131,14 @@ following incompatible changes:</para>
|
||||||
Other types dependencies should be unaffected.
|
Other types dependencies should be unaffected.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
The <literal>memcached</literal> service no longer accept dynamic socket
|
||||||
|
paths via <option>services.memcached.socket</option>. Unix sockets can be
|
||||||
|
still enabled by <option>services.memcached.enableUnixSocket</option> and
|
||||||
|
will be accessible at <literal>/run/memcached/memcached.sock</literal>.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
|
@ -197,7 +197,7 @@
|
||||||
#input = 174; # unused
|
#input = 174; # unused
|
||||||
sddm = 175;
|
sddm = 175;
|
||||||
tss = 176;
|
tss = 176;
|
||||||
memcached = 177;
|
#memcached = 177; removed 2018-01-03
|
||||||
ntp = 179;
|
ntp = 179;
|
||||||
zabbix = 180;
|
zabbix = 180;
|
||||||
#redis = 181; removed 2018-01-03
|
#redis = 181; removed 2018-01-03
|
||||||
|
@ -475,7 +475,7 @@
|
||||||
input = 174;
|
input = 174;
|
||||||
sddm = 175;
|
sddm = 175;
|
||||||
tss = 176;
|
tss = 176;
|
||||||
#memcached = 177; # unused
|
#memcached = 177; # unused, removed 2018-01-03
|
||||||
#ntp = 179; # unused
|
#ntp = 179; # unused
|
||||||
#zabbix = 180; # unused
|
#zabbix = 180; # unused
|
||||||
#redis = 181; # unused, removed 2018-01-03
|
#redis = 181; # unused, removed 2018-01-03
|
||||||
|
|
|
@ -40,11 +40,7 @@ in
|
||||||
description = "The port to bind to";
|
description = "The port to bind to";
|
||||||
};
|
};
|
||||||
|
|
||||||
socket = mkOption {
|
enableUnixSocket = mkEnableOption "unix socket at /run/memcached/memcached.sock";
|
||||||
default = "";
|
|
||||||
description = "Unix socket path to listen on. Setting this will disable network support";
|
|
||||||
example = "/var/run/memcached";
|
|
||||||
};
|
|
||||||
|
|
||||||
maxMemory = mkOption {
|
maxMemory = mkOption {
|
||||||
default = 64;
|
default = 64;
|
||||||
|
@ -68,31 +64,40 @@ in
|
||||||
|
|
||||||
config = mkIf config.services.memcached.enable {
|
config = mkIf config.services.memcached.enable {
|
||||||
|
|
||||||
users.extraUsers.memcached =
|
users.extraUsers = optional (cfg.user == "memcached") {
|
||||||
{ name = cfg.user;
|
name = "memcached";
|
||||||
uid = config.ids.uids.memcached;
|
description = "Memcached server user";
|
||||||
description = "Memcached server user";
|
};
|
||||||
};
|
|
||||||
|
|
||||||
environment.systemPackages = [ memcached ];
|
environment.systemPackages = [ memcached ];
|
||||||
|
|
||||||
systemd.services.memcached =
|
systemd.services.memcached = {
|
||||||
{ description = "Memcached server";
|
description = "Memcached server";
|
||||||
|
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
after = [ "network.target" ];
|
after = [ "network.target" ];
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
ExecStart =
|
PermissionsStartOnly = true;
|
||||||
let
|
ExecStartPre = optionals cfg.enableUnixSocket [
|
||||||
networking = if cfg.socket != ""
|
"${pkgs.coreutils}/bin/install -d -o ${cfg.user} /run/memcached/"
|
||||||
then "-s ${cfg.socket}"
|
"${pkgs.coreutils}/bin/chown -R ${cfg.user} /run/memcached/"
|
||||||
else "-l ${cfg.listen} -p ${toString cfg.port}";
|
];
|
||||||
in "${memcached}/bin/memcached ${networking} -m ${toString cfg.maxMemory} -c ${toString cfg.maxConnections} ${concatStringsSep " " cfg.extraOptions}";
|
ExecStart =
|
||||||
|
let
|
||||||
|
networking = if cfg.enableUnixSocket
|
||||||
|
then "-s /run/memcached/memcached.sock"
|
||||||
|
else "-l ${cfg.listen} -p ${toString cfg.port}";
|
||||||
|
in "${memcached}/bin/memcached ${networking} -m ${toString cfg.maxMemory} -c ${toString cfg.maxConnections} ${concatStringsSep " " cfg.extraOptions}";
|
||||||
|
|
||||||
User = cfg.user;
|
User = cfg.user;
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
imports = [
|
||||||
|
(mkRemovedOptionModule ["services" "memcached" "socket"] ''
|
||||||
|
This option was replaced by a fixed unix socket path at /run/memcached/memcached.sock enabled using services.memached.enableUnixSocket.
|
||||||
|
'')
|
||||||
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue