Skip to main content

Memcached systemd file

Comments

4 comments

  • cPanelMichael
    Hello, The /etc/systemd/system/multi-user.target.wants/memcached.service does not exist on a test CentOS 7 system when installing the Memcached via the EA4 experimental repo: # stat /etc/systemd/system/multi-user.target.wants/memcached.service stat: cannot stat "/etc/systemd/system/multi-user.target.wants/memcached.service": No such file or directory
    Instead, it uses the following file: /usr/lib/systemd/system/memcached.service
    To clarify, are you manually setting up the /etc/systemd/system/multi-user.target.wants/memcached.service file? Thank you.
    0
  • vikelidiskostas
    This file: /etc/systemd/system/multi-user.target.wants/memcached.service
    is a link to: /usr/lib/systemd/system/memcached.service
    The truth is that the link is automatically created from systemd when you enable the service with the command: [root@server]# systemctl enable memcached.service Created symlink from /etc/systemd/system/multi-user.target.wants/memcached.service to /usr/lib/systemd/system/memcached.service.
    Do the same in your test system and you will see that the link will be created. So the problem is that each time a new version of ea-memcached package is installed it overwrites the /usr/lib/systemd/system/memcached.service file. More specific the problem is the $USER variable. When this variable is present the service is not started. When i replace the $USER variable with the "memcached" string (compare the unit files in my initial post) the service is successfully started.
    0
  • cPanelMichael
    Hello, The "$USER" variable should work, because it links to the following environment file: /etc/sysconfig/memcached
    Within this file, you should see an entry like this: USER="memcached"
    I left the default "$USER" entry in the /usr/lib/systemd/system/memcached.service file, and rebooted the system. Upon doing so, memcached was started successfully: Jan 24 09:50:03 cp70 systemd[1]: Starting Memcached... -- Subject: Unit memcached.service has begun start-up -- Defined-By: systemd -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- -- Unit memcached.service has begun starting up.
    What does the /etc/sysconfig/memcached file look like on your system? Thank you.
    0
  • vikelidiskostas
    Thanks for the reply. I wasn't aware of the file: /etc/sysconfig/memcached
    The contents of this file in my system is this: user=memcached PORT=11211
    To solve the problem i have done the following: I restored the unit file /usr/lib/systemd/system/memcached.service in its original state and now it looks like this: [Unit] Description=Memcached Before=httpd.service After=network.target [Service] Type=simple EnvironmentFile=-/etc/sysconfig/memcached ExecStart=/usr/bin/memcached -u $USER -p $PORT -m $CACHESIZE -c $MAXCONN $OPTIONS [Install] WantedBy=multi-user.target
    Then i capitilized the variable's name in /etc/sysconfig/memcached. Now this file looks like this: USER=memcached PORT=11211
    Problem solved. The service is successfully started, restarted etc. Thanks for the help!!!
    0

Please sign in to leave a comment.