v2ray-core: V2ray 5.1.0 unable to run as a systemd service
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:
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (4 by maintainers)
处理方式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 就好啦
Hi, I just had the same
exit-codeerror problem. You can get more detailed information about the error by the commandjournalctl -u v2ray(scroll down to the end!). In my case, it told me the error happened becausev2raycouldn’t initial theaccess.logfile, so I deleted that file and this timesystemctl start v2rayworked properly. Your problem may be different, but thejournalctlwas the place I didn’t check for two hours of debugging this problem. And it seems likesystemctl status v2rayis not providing much information about the error.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.
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, notv2ray -configThank you, I rolled back to v4.45.0 with the command
bash install-release.sh --version v4.45.0