Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 564926

Summary: Memcached systemd service file not using memcached.conf
Product: Gentoo Linux Reporter: zasire <zasire>
Component: Current packagesAssignee: Matthew Thode ( prometheanfire ) <prometheanfire>
Status: RESOLVED INVALID    
Severity: normal CC: grknight, robbat2
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description zasire 2015-11-05 10:02:58 UTC
The delivered memcached.service for systemd is shipped with hard coded settings and no reference to /etc/conf.d/memcached. I know this is .service file is somewhat default on most distributions, as you can find it as a default example all over google. But its not a good solution. It should be possible to edit memcached behavior (using sockets, for example) through config files.

Here is an example .service file:

[Unit]
After=network.target
Description=High-performance, distributed memory object caching system
Documentation=man:memcached(1)
Documentation=http://code.google.com/p/memcached/

[Service]
EnvironmentFile=/etc/conf.d/memcached

# create socket/pid directory
PermissionsStartOnly=true
ExecStartPre=-/bin/mkdir -p /var/run/memcached
ExecStartPre=-/bin/chown -f ${MEMCACHED_RUNAS} /var/run/memcached

# drop privileges and start daemon
ExecStart=/usr/bin/memcached -m ${MEMUSAGE} -c ${MAXCONN} -s ${SOCKET} -a ${SOCKET_MASK} -P ${PIDBASE}.pid -u ${MEMCACHED_RUNAS}

# cleanup (fixme)
ExecStop=/bin/rm -f ${PIDFile}
ExecStop=/bin/rm -f ${SOCKET}

[Install]
WantedBy=multi-user.target

I had to add ExecPreStart since memcached /var/run does not exist otherwise and memcached will fail. There might be a better option. This might be not perfect, but something like this should be default.

Reproducible: Always

Steps to Reproduce:
1. emerge memcached
2. edit /etc/conf.d/memcached
3. systemctl start memcached

Actual Results:  
Memcached is not doing anything, it should to according to config file

Expected Results:  
Memcached should work according to config file
Comment 1 Brian Evans (RETIRED) gentoo-dev 2015-11-10 14:07:28 UTC
The OpenRC maintainer has said that only OpenRC should be using anything in /etc/conf.d

Systemd is fine to use an environment file, but you should use a different path.
Comment 2 zasire 2015-11-10 14:12:31 UTC
Thanks allot for clarification. I've just started with systemd to give it a try at least and after posting this bug i've found out about /etc/systemd/ myself. Seems like bug is resolved then. Thanks!
Comment 3 Brian Evans (RETIRED) gentoo-dev 2015-11-10 14:23:13 UTC
User considers it solved as a non-issue