Shadowsocks-libev: Start service failed on Ubuntu 16.04

Created on 11 Nov 2017  ·  8Comments  ·  Source: shadowsocks/shadowsocks-libev

What version of shadowsocks-libev are you using?

shadowsocks-libev/xenial,now 3.1.0-1~ppa2x amd64 [installed]

What operating system are you using?

Ubuntu 16.04

What did you do?

systemctl start shadowsocks-libev.service
systemctl status shadowsocks-libev.service

What did you expect to see?

run

What did you see instead?

● shadowsocks-libev.service - Shadowsocks-libev Default Server Service
Loaded: loaded (/lib/systemd/system/shadowsocks-libev.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since 六 2017-11-11 16:09:59 CST; 7min ago
Docs: man:shadowsocks-libev(8)
Process: 2248 ExecStart=/usr/bin/ss-server -c $CONFFILE $DAEMON_ARGS (code=exited, status=255)
Main PID: 2248 (code=exited, status=255)

11月 11 16:09:59 ygy-ubuntu systemd[1]: Started Shadowsocks-libev Default Server Service.
11月 11 16:09:59 ygy-ubuntu systemd[1]: shadowsocks-libev.service: Main process exited, code=exited, status=255/n/a
11月 11 16:09:59 ygy-ubuntu systemd[1]: shadowsocks-libev.service: Unit entered failed state.
11月 11 16:09:59 ygy-ubuntu systemd[1]: shadowsocks-libev.service: Failed with result 'exit-code'.

What is your config in detail (with all sensitive info masked)?

{
"server":"",
"server_port":14276,
"local_port":1080,
"password":"
*",
"timeout":60,
"method":"chacha20-ietf-poly1305"
}

Thanks for your help!

question

Most helpful comment

Run into the same condition on Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-97-generic x86_64), with ss-libev 3.1.3-1~ppa1x.

I got logs:

● shadowsocks-libev.service - Shadowsocks-libev Default Server Service
   Loaded: loaded (/lib/systemd/system/shadowsocks-libev.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Thu 2018-01-18 14:26:02 UTC; 5s ago
     Docs: man:shadowsocks-libev(8)
  Process: 26744 ExecStart=/usr/bin/ss-server -c $CONFFILE $DAEMON_ARGS (code=exited, status=255)
 Main PID: 26744 (code=exited, status=255)

Jan 18 14:26:02 server systemd[1]: Started Shadowsocks-libev Default Server Service.
Jan 18 14:26:02 server  systemd[1]: shadowsocks-libev.service: Main process exited, code=exited, status=255/n/a
Jan 18 14:26:02 server  systemd[1]: shadowsocks-libev.service: Unit entered failed state.
Jan 18 14:26:02 server  systemd[1]: shadowsocks-libev.service: Failed with result 'exit-code'.

Sometimes I got ONE MORE line: (the 2nd line below)

Jan 18 14:21:47 server  systemd[1]: Started Shadowsocks-libev Default Server Service.
Jan 18 14:21:47 server  ss-server[26682]:  2018-01-18 14:21:47 ERROR: Invalid config path.
...

While running ss-server -c config.json just works (I logged in as root).


Searched the Web and found these. The problem _might_ be caused by systemd, which prevents services run as nobody to read /etc/shadowsocks-libev/config.json (the config file is owned by root and has mode 644, by default).

Temporarily I commented out User=nobody and Group=nogroup in file /lib/systemd/system/shadowsocks-libev.service, and the service started. But I'm not sure if that's a good practice.


FYI: FS#56828 - [systemd] Service units with User=nobody are unable to access config file owned by nobody
Also: https://github.com/systemd/systemd/issues/7717, https://github.com/systemd/systemd/issues/7906

All 8 comments

Is this machine in question a server or a client?

If it's a client you should not run shadowsocks service, because it activates ss-server. You should use ss-local or ss-redir.

ss-server -c config.json says what?

Run into the same condition on Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-97-generic x86_64), with ss-libev 3.1.3-1~ppa1x.

I got logs:

● shadowsocks-libev.service - Shadowsocks-libev Default Server Service
   Loaded: loaded (/lib/systemd/system/shadowsocks-libev.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Thu 2018-01-18 14:26:02 UTC; 5s ago
     Docs: man:shadowsocks-libev(8)
  Process: 26744 ExecStart=/usr/bin/ss-server -c $CONFFILE $DAEMON_ARGS (code=exited, status=255)
 Main PID: 26744 (code=exited, status=255)

Jan 18 14:26:02 server systemd[1]: Started Shadowsocks-libev Default Server Service.
Jan 18 14:26:02 server  systemd[1]: shadowsocks-libev.service: Main process exited, code=exited, status=255/n/a
Jan 18 14:26:02 server  systemd[1]: shadowsocks-libev.service: Unit entered failed state.
Jan 18 14:26:02 server  systemd[1]: shadowsocks-libev.service: Failed with result 'exit-code'.

Sometimes I got ONE MORE line: (the 2nd line below)

Jan 18 14:21:47 server  systemd[1]: Started Shadowsocks-libev Default Server Service.
Jan 18 14:21:47 server  ss-server[26682]:  2018-01-18 14:21:47 ERROR: Invalid config path.
...

While running ss-server -c config.json just works (I logged in as root).


Searched the Web and found these. The problem _might_ be caused by systemd, which prevents services run as nobody to read /etc/shadowsocks-libev/config.json (the config file is owned by root and has mode 644, by default).

Temporarily I commented out User=nobody and Group=nogroup in file /lib/systemd/system/shadowsocks-libev.service, and the service started. But I'm not sure if that's a good practice.


FYI: FS#56828 - [systemd] Service units with User=nobody are unable to access config file owned by nobody
Also: https://github.com/systemd/systemd/issues/7717, https://github.com/systemd/systemd/issues/7906

Stop the service
-systemctl stop kafka
Restart the service
-systemctl start kafka

Run into the same condition on Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-97-generic x86_64), with ss-libev 3.1.3-1~ppa1x.

I got logs:

● shadowsocks-libev.service - Shadowsocks-libev Default Server Service
   Loaded: loaded (/lib/systemd/system/shadowsocks-libev.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Thu 2018-01-18 14:26:02 UTC; 5s ago
     Docs: man:shadowsocks-libev(8)
  Process: 26744 ExecStart=/usr/bin/ss-server -c $CONFFILE $DAEMON_ARGS (code=exited, status=255)
 Main PID: 26744 (code=exited, status=255)

Jan 18 14:26:02 server systemd[1]: Started Shadowsocks-libev Default Server Service.
Jan 18 14:26:02 server  systemd[1]: shadowsocks-libev.service: Main process exited, code=exited, status=255/n/a
Jan 18 14:26:02 server  systemd[1]: shadowsocks-libev.service: Unit entered failed state.
Jan 18 14:26:02 server  systemd[1]: shadowsocks-libev.service: Failed with result 'exit-code'.

Sometimes I got ONE MORE line: (the 2nd line below)

Jan 18 14:21:47 server  systemd[1]: Started Shadowsocks-libev Default Server Service.
Jan 18 14:21:47 server  ss-server[26682]:  2018-01-18 14:21:47 ERROR: Invalid config path.
...

While running ss-server -c config.json just works (I logged in as root).

Searched the Web and found these. The problem _might_ be caused by systemd, which prevents services run as nobody to read /etc/shadowsocks-libev/config.json (the config file is owned by root and has mode 644, by default).

Temporarily I commented out User=nobody and Group=nogroup in file /lib/systemd/system/shadowsocks-libev.service, and the service started. But I'm not sure if that's a good practice.

FYI: FS#56828 - [systemd] Service units with User=nobody are unable to access config file owned by nobody
Also: systemd/systemd#7717, systemd/systemd#7906

● shadowsocks-libev.service - Shadowsocks-libev Default Server Service
Loaded: loaded (/usr/lib/systemd/system/shadowsocks-libev.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since 四 2019-09-05 19:01:30 CST; 4s ago
Docs: man:shadowsocks-libev(8)
Process: 30242 ExecStart=/usr/bin/ss-server -c $CONFFILE $DAEMON_ARGS (code=exited, status=216/GROUP)
Main PID: 30242 (code=exited, status=216/GROUP)

9月 05 19:01:30 localhost.localdomain systemd[1]: Started Shadowsocks-libev Default Server Service.
9月 05 19:01:30 localhost.localdomain systemd[1]: shadowsocks-libev.service: main process exited, code=exited, status=216/GROUP
9月 05 19:01:30 localhost.localdomain systemd[1]: Unit shadowsocks-libev.service entered failed state.
9月 05 19:01:30 localhost.localdomain systemd[1]: shadowsocks-libev.service failed.
[root@localhost /etc/shadowsocks-libev 19:01:35 4.2 ]# ss-server -c config.json
2019-09-05 19:02:05 ERROR: 2:0: Expected : before 4
[root@localhost /etc/shadowsocks-libev 19:02:05 4.2 ]#

Run into the same condition on Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-97-generic x86_64), with ss-libev 3.1.3-1~ppa1x.

I got logs:

● shadowsocks-libev.service - Shadowsocks-libev Default Server Service
   Loaded: loaded (/lib/systemd/system/shadowsocks-libev.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Thu 2018-01-18 14:26:02 UTC; 5s ago
     Docs: man:shadowsocks-libev(8)
  Process: 26744 ExecStart=/usr/bin/ss-server -c $CONFFILE $DAEMON_ARGS (code=exited, status=255)
 Main PID: 26744 (code=exited, status=255)

Jan 18 14:26:02 server systemd[1]: Started Shadowsocks-libev Default Server Service.
Jan 18 14:26:02 server  systemd[1]: shadowsocks-libev.service: Main process exited, code=exited, status=255/n/a
Jan 18 14:26:02 server  systemd[1]: shadowsocks-libev.service: Unit entered failed state.
Jan 18 14:26:02 server  systemd[1]: shadowsocks-libev.service: Failed with result 'exit-code'.

Sometimes I got ONE MORE line: (the 2nd line below)

Jan 18 14:21:47 server  systemd[1]: Started Shadowsocks-libev Default Server Service.
Jan 18 14:21:47 server  ss-server[26682]:  2018-01-18 14:21:47 ERROR: Invalid config path.
...

While running ss-server -c config.json just works (I logged in as root).

Searched the Web and found these. The problem _might_ be caused by systemd, which prevents services run as nobody to read /etc/shadowsocks-libev/config.json (the config file is owned by root and has mode 644, by default).

Temporarily I commented out User=nobody and Group=nogroup in file /lib/systemd/system/shadowsocks-libev.service, and the service started. But I'm not sure if that's a good practice.

FYI: FS#56828 - [systemd] Service units with User=nobody are unable to access config file owned by nobody
Also: systemd/systemd#7717, systemd/systemd#7906

2019-09-05 19:02:05 ERROR: 2:0: Expected : before 4
[root@localhost /etc/shadowsocks-libev 19:02:05 4.2 ]# cd /usr/lib/systemd/system
[root@localhost /usr/lib/systemd/system 19:04:15 4.2 ]# cat shadowsocks-libev.service

This file is part of shadowsocks-libev.

#

Shadowsocks-libev is free software; you can redistribute it and/or modify

it under the terms of the GNU General Public License as published by

the Free Software Foundation; either version 3 of the License, or

(at your option) any later version.

#

This file is default for RPM packaging. See also

/etc/sysconfig/shadowsocks-libev for environment variables.

[Unit]
Description=Shadowsocks-libev Default Server Service
Documentation=man:shadowsocks-libev(8)
After=network.target network-online.target

[Service]
Type=simple
EnvironmentFile=/etc/sysconfig/shadowsocks-libev
User=nobody
Group=nogroup
LimitNOFILE=32768
ExecStart=/usr/bin/ss-server -c "$CONFFILE" $DAEMON_ARGS
CapabilityBoundingSet=CAP_NET_BIND_SERVICE

[Install]
WantedBy=multi-user.target

Is this machine in question a server or a client?

If it's a client you should not run shadowsocks service, because it activates ss-server. You should use ss-local or ss-redir.

i'm sorry , how it works?

WavinFlag's comment worked for me:

Searched the Web and found these. The problem might be caused by systemd, which prevents services run as nobody to read /etc/shadowsocks-libev/config.json (the config file is owned by root and has mode 644, by default).

I'd copied over the config.json file. using chmod 644 config.json on the file solved the issue. Thanks WavinFlag!

Was this page helpful?
0 / 5 - 0 ratings