Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V2ray 5.1.0 unable to run as a systemd service #1956

Closed
Heclalava opened this issue Sep 8, 2022 · 16 comments
Closed

V2ray 5.1.0 unable to run as a systemd service #1956

Heclalava opened this issue Sep 8, 2022 · 16 comments
Labels

Comments

@Heclalava
Copy link

What version of V2Ray are you using?

5.1.0

What's your scenario of using V2Ray?

I have installed a new server, and the script automatically installed v 5.1.0, unable to run v2ray as a service on Debian 10 Server.

What problems have you encountered?

Starting v2ray as a service exits with (code=exited, status=2). Full error is the following
Process: 1173 ExecStart=/usr/local/bin/v2ray -config /usr/local/etc/v2ray/config.json (code=exited, status=2)

The problem is ExecStart. If I run the line /usr/local/bin/v2ray -config /usr/local/etc/v2ray/config.json in terminal directly I get the following output:
flag provided but not defined: -config Usage of /usr/local/bin/v2ray:

However if I run this /usr/local/bin/v2ray run -c /usr/local/etc/v2ray/config.json then v2ray will run.

So I edited as root /etc/systemd/system/v2ray.service and changed the file to have the following line
ExecStart=/usr/local/bin/v2ray run -c /usr/local/etc/v2ray/config.json

I then ran the following
systemctl daemon-reload && systemctl restart v2ray

However when I run systemctl status v2ray I get the following output:

● v2ray.service - V2Ray Service
   Loaded: loaded (/etc/systemd/system/v2ray.service; enabled; vendor preset: enabled)
  Drop-In: /etc/systemd/system/v2ray.service.d
           └─10-donot_touch_single_conf.conf
   Active: failed (Result: exit-code) since Thu 2022-09-08 02:38:45 UTC; 11min ago
     Docs: https://www.v2fly.org/
  Process: 1173 ExecStart=/usr/local/bin/v2ray -config /usr/local/etc/v2ray/config.json (code=exited, status=2)
 Main PID: 1173 (code=exited, status=2)

Sep 08 02:38:45 ONEVPS220908004518 systemd[1]: v2ray.service: Main process exited, code=exited, status=2/INVALIDARGUM
Sep 08 02:38:45 ONEVPS220908004518 systemd[1]: v2ray.service: Failed with result 'exit-code'.
Sep 08 02:38:45 ONEVPS220908004518 systemd[1]: v2ray.service: Service RestartSec=100ms expired, scheduling restart.
Sep 08 02:38:45 ONEVPS220908004518 systemd[1]: v2ray.service: Scheduled restart job, restart counter is at 5.
Sep 08 02:38:45 ONEVPS220908004518 systemd[1]: Stopped V2Ray Service.
Sep 08 02:38:45 ONEVPS220908004518 systemd[1]: v2ray.service: Start request repeated too quickly.
Sep 08 02:38:45 ONEVPS220908004518 systemd[1]: v2ray.service: Failed with result 'exit-code'.
Sep 08 02:38:45 ONEVPS220908004518 systemd[1]: Failed to start V2Ray Service.

Please note that it is defaulting back to ExecStart=/usr/local/bin/v2ray -config /usr/local/etc/v2ray/config.json and not accepting my edited ExecStart=/usr/local/bin/v2ray run -c /usr/local/etc/v2ray/config.json

What's your expectation?

v2ray should run as a service on the server, however unable to as ExeStart is defaulting back to a faulty launch command.

Please attach your configuration here

{
"inbounds": [{
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
]
},
"port": 8388,
"listen": "127.0.0.1",
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "4a4a022b-a073-4094-899a-ca04a5c232cd",
"level": 1,
"alterId": 0,
"security": "auto"
}
]
},
"streamSettings": {
"network": "ws",
"wsSettings": {
"path": "/websocket/"
}
}
}],
"outbounds": [{
"protocol": "freedom",
"settings": {}
},{
"protocol": "blackhole",
"settings": {},
"tag": "blocked"
}],
"routing": {
"domainStrategy": "AsIs",
"rules": [
{
"type": "field",
"ip": ["geoip:private", "geoip:cn"],
"outboundTag": "block",
"protocol": ["bittorrent"]
}
]
}
}

If V2Ray cannot start up, please attach output from --test command

flag provided but not defined: -config
Usage of /usr/local/bin/v2ray:

@cubercsl
Copy link

cubercsl commented Sep 8, 2022

@Heclalava
Copy link
Author

Heclalava commented Sep 8, 2022

v2fly/fhs-install-v2ray#243

Thank you, I rolled back to v4.45.0 with the command
bash install-release.sh --version v4.45.0

@suienzan
Copy link

suienzan commented Sep 8, 2022

In your output: Process: 1173 ExecStart=/usr/local/bin/v2ray -config /usr/local/etc/v2ray/config.json (code=exited, status=2)

Your systemd unit is still using a wrong command. You should use v2ray run -config, not v2ray -config

@wenge110110
Copy link

处理方式1:
rm -rf /etc/systemd/system/v2ray.service.d/10-donot_touch_single_conf.conf
systemctl daemon-reload
systemctl restart v2ray
处理方式2:
vi /etc/systemd/system/v2ray.service.d/10-donot_touch_single_conf.conf
把ExecStart=/usr/local/bin/v2ray -config /usr/local/etc/v2ray/config.json
改为ExecStart=/usr/local/bin/v2ray run -config /usr/local/etc/v2ray/config.json
systemctl daemon-reload
systemctl restart v2ray
处理方式3:
切回老版本:
bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) --version v4.45.2 就好啦

@lhzw
Copy link

lhzw commented Sep 8, 2022

Don't see any benefit of adding a 'run' to break the software, do not like breaking updates.

In your output: Process: 1173 ExecStart=/usr/local/bin/v2ray -config /usr/local/etc/v2ray/config.json (code=exited, status=2)

Your systemd unit is still using a wrong command. You should use v2ray run -config, not v2ray -config

@Heclalava
Copy link
Author

In your output: Process: 1173 ExecStart=/usr/local/bin/v2ray -config /usr/local/etc/v2ray/config.json (code=exited, status=2)

Your systemd unit is still using a wrong command. You should use v2ray run -config, not v2ray -config

The issue is this was a fresh install. It's not working out the box. I understand that I can edit files to get it working. The problem is it's not working on a fresh install. Editing files shouldn't be necessary on a new install just to get it to work.

@digglife
Copy link
Contributor

digglife commented Sep 8, 2022

I don't see anything wrong of the systemd script in the repo, it uses v2ray run -config, which was actually fixed 8 months ago. Download any package for Linux from the release page and you can find it out.

This is the repo for the v2ray itself, not for installation script or third party packages. Nothing here in this repo can install or configure the software for you, instead, it only provides all the necessary files (including the correct systemd script) for you to install. So it's an issue of the installation script you uses, not v2ray.

Also, there is nothing wrong to introduce break changes in a major version update, on the contrary, that's exactly what's a major version update for.

@Heclalava
Copy link
Author

I don't see anything wrong of the systemd script in the repo, it uses v2ray run -config, which was actually fixed 8 months ago. Download any package for Linux from the release page and you can find it out.

This is the repo for the v2ray itself, not for installation script or third party packages. Nothing here in this repo can install or configure the software for you, instead, it only provides all the necessary files (including the correct systemd script) for you to install. So it's an issue of the installation script you uses, not v2ray.

Also, there is nothing wrong to introduce break changes in a major version update, on the contrary, that's exactly what's a major version update for.

Well I installed from the script install-release.sh downloaded from the v2fly GitHub. I followed official documentation for install and this is the result of how it was setup.

@lhzw
Copy link

lhzw commented Sep 9, 2022

Me too, I used install-release.sh to do the updating, and it's just broken and cannot work any more, until reverted to an old version.

Well I installed from the script install-release.sh downloaded from the v2fly GitHub. I followed official documentation for install and this is the result of how it was setup.

To me, the most important point to a software is backward compatibility, a good one does its job silently, without causing trouble to its users.
A good software will first say that a certain feature is deprecated, please use xxx, and it will be removed in the future version, instead of suddenly making a destructive update.

@suienzan
Copy link

suienzan commented Sep 9, 2022

In your output: Process: 1173 ExecStart=/usr/local/bin/v2ray -config /usr/local/etc/v2ray/config.json (code=exited, status=2)
Your systemd unit is still using a wrong command. You should use v2ray run -config, not v2ray -config

The issue is this was a fresh install. It's not working out the box. I understand that I can edit files to get it working. The problem is it's not working on a fresh install. Editing files shouldn't be necessary on a new install just to get it to work.

I don't use the install-release.sh so I didn't got why you have an wrong command at first.

Now I wonder why the install-release.sh write a systemd script itself instead of using the offical one.

@Heclalava
Copy link
Author

In your output: Process: 1173 ExecStart=/usr/local/bin/v2ray -config /usr/local/etc/v2ray/config.json (code=exited, status=2)
Your systemd unit is still using a wrong command. You should use v2ray run -config, not v2ray -config

The issue is this was a fresh install. It's not working out the box. I understand that I can edit files to get it working. The problem is it's not working on a fresh install. Editing files shouldn't be necessary on a new install just to get it to work.

I don't use the install-release.sh so I didn't got why you have an wrong command at first.

Now I wonder why the install-release.sh write a systemd script itself instead of using the offical one.

Install-release.sh is the official script from the v2fly documentation to install v2ray. So the issue appears to be in the script.

@digglife
Copy link
Contributor

digglife commented Sep 9, 2022

Well I installed from the script install-release.sh downloaded from the v2fly GitHub. I followed official documentation for install and this is the result of how it was setup.

Exactly, this is not the repo for the script, you got an error because of an install script, it's better to report the issue to the script instead.

To me, the most important point to a software is backward compatibility, a good one does its job silently, without causing trouble to its users.
A good software will first say that a certain feature is deprecated, please use xxx, and it will be removed in the future version, instead of suddenly making a destructive update.

  1. The only reason this release affects you is that you uses install-release.sh and it has not been updated accordingly, not because v2ray-core introduces break changes.
  2. Even if this command change causes troubles to you directly, it's supposed to do so because this is the first Preview release of v5.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2023

This issue is stale because it has been open 120 days with no activity. Remove stale label or comment or this will be closed in 5 days

@github-actions github-actions bot added the Stale label Jan 8, 2023
@AlirezaAtoZ
Copy link

Hi, I just had the same exit-code error problem.
You can get more detailed information about the error by the command journalctl -u v2ray (scroll down to the end!).
In my case, it told me the error happened because v2ray couldn't initial the access.log file, so I deleted that file and this time systemctl start v2ray worked properly.
Your problem may be different, but the journalctl was the place I didn't check for two hours of debugging this problem. And it seems like systemctl status v2ray is not providing much information about the error.

@github-actions github-actions bot removed the Stale label Jan 12, 2023
@github-actions
Copy link
Contributor

This issue is stale because it has been open 120 days with no activity. Remove stale label or comment or this will be closed in 5 days

@github-actions github-actions bot added the Stale label May 13, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 18, 2023
@pmhw
Copy link

pmhw commented Jul 3, 2024

删除 /etc/systemd/system v2ray.service 中的 AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE 这一行 大部分是这个原因造成的

如果还不行 journalctl -u v2ray 空格向下滚动查看更多错误信息
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants