litespeedtech / litespeedtech/lsmcd

LSMCD not work with unix socket

Open
#27 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
39
Forks
18
PR merge metrics
No merged PRs in 30d

Description

I use cPanel and Cloulinux and Litespeed
I installed the LSMCD via cPanel plugin file in this command:

```bash
sudo git clone https://github.com/litespeedtech/lsmcd.git
sudo cd lsmcd
sudo ./lsmcd_cpanel.sh
```

LSMCD is working properly with `TCP` connection, but when I configured to `unix socket`, it shows nothing.

**test.php**
```php
setOption(Memcached::OPT_BINARY_PROTOCOL, true);
$mc->setOption(Memcached::OPT_COMPRESSION, false);
$mc->addServer('/tmp/lsmcd/lsmcd.sock', 0);
$mc->setSaslAuthData('testuser', 'testpass');
$mc->set("foo", "bar");
$value = $mc->get('foo');
echo $value;
```
And it doesn't show anything.

**/usr/local/lsmcd/conf/node.conf**
```bash
Repl.HeartBeatReq=30
Repl.HeartBeatRetry=3000
Repl.MaxTidPacket=2048000
Repl.GzipStream=YES
Repl.LbAddrs=127.0.0.1:12340
Repl.ListenSvrAddr=127.0.0.1:12340
REPL.DispatchAddr=127.0.0.1:5501
RepldSockPath=/tmp/repld.usock
CACHED.PRIADDR=127.0.0.1:11000

#CACHED.ADDR=127.0.0.1:11211
CACHED.ADDR=UDS:///tmp/lsmcd/lsmcd.sock
#default is 8, it can be bigger depending on cache data amount
Cached.Slices=8
Cached.Slice.Priority.0=100
Cached.Slice.Priority.1=100
Cached.Slice.Priority.2=100
Cached.Slice.Priority.3=100
Cached.Slice.Priority.4=100
Cached.Slice.Priority.5=100
Cached.Slice.Priority.6=100
Cached.Slice.Priority.7=100

Cached.ShmDir=/dev/shm/lsmcd
Cached.UseSasl=true
Cached.DataByUser=true
Cached.Anonymous=false
Cached.SaslDB=/etc/sasllsmcd

##this is the global setting, no need to have per slice configuration.
User=nobody
Group=nobody
#depends CPU core
CachedProcCnt=4
CachedSockPath=/tmp/cached.usock.
TmpDir=/tmp/lsmcd
LogLevel=notice
#LogLevel=dbg_medium
LogFile=/tmp/lsmcd.log
```

But it works when I switch to `TCP`:
```bash
CACHED.ADDR=127.0.0.1:11211
#CACHED.ADDR=UDS:///tmp/lsmcd/lsmcd.sock
```

```bash
sudo systemctl restart lsmcd
```

```php
$mc->addServer('127.0.0.1', 11211);
```

it returns **"bar"**

In this article: [Using Memcached in a UNIX socket](https://docs.litespeedtech.com/lscache/lscwp/admin/#using-memcached-in-a-unix-socket), it is mentioned that:

> 1.Stop Memcached systemctl stop memcached
> 2. Copy the service file cp /usr/lib/systemd/system/memcached.service /etc/systemd/system/memcached.service
> 3. Add the following content to /etc/systemd/system/memcached.service. After [Service], please change username to the same user that runs PHP: User=username Group=username The contents of the file should look like this:

But there isn't any `memcached` service in the system. Because I installed `lscmd`, not memcached.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with test.php and /usr/local/lsmcd/conf/node.conf, comparing the UDS and TCP configurations and the documented UNIX-socket setup. Reproduce the PHP Memcached request after restarting lsmcd, then inspect the configured socket and /tmp/lsmcd.log. Done means the UNIX-socket configuration returns the stored value like the TCP configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, php
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.