master-coder-ll / v2ray-web-manager

v2ray-web-manager 是一个v2ray的面板,也是一个集群的解决方案;同时增加了流量控制/账号管理/限速等功能。key: admin , panel ,web,cluster,集群,proxy
MIT License
1.44k stars 485 forks source link

管理脚本参考 #62

Closed master-coder-ll closed 1 year ago

master-coder-ll commented 4 years ago

Create v2panel-start.sh vi /opt/jar/v2panel-start.sh

!/bin/sh

nohup java -jar -Xmx40m -XX:MaxDirectMemorySize=8M -XX:MaxMetaspaceSize=80m /opt/jar/admin.jar --spring.config.location=/opt/jar/admin.yaml > /dev/null 2>&1 & echo $! > /var/run/v2ray-admin.pid nohup java -jar -Xmx40m -XX:MaxDirectMemorySize=8M -XX:MaxMetaspaceSize=48m /opt/jar/v2ray-proxy.jar --spring.config.location=/opt/jar/proxy.yaml > /dev/null 2>&1 & echo $! > /var/run/v2ray-proxy.pid

Create v2panel-stop.sh vi /opt/jar/v2panel-stop.sh

!/bin/sh

PID1=${cat /var/run/v2ray-admin.pid} kill -15 $PID1 PID2=${cat /var/run/v2ray-proxy.pid} kill -15 $PID2

Register v2panel service vi /etc/systemd/system/v2panel.service

[Unit] Description=v2ray-web-manager After=network.target network-online.target nss-lookup.target mysql.service mariadb.service mysqld.service [Service] Type=forking StandardError=journal ExecStart=/opt/jar/v2panel-start.sh ExecStop=/opt/jar/v2panel-stop.sh [Install] WantedBy=multi-user.target

Set autostart systemctl enable v2panel Start service systemctl start v2panel Stop service systemctl stop v2panel

Originally posted by @savaza in https://github.com/master-coder-ll/v2ray-web-manager/issues/59#issuecomment-605067523

lati0s commented 3 years ago

針對Linux作業系統比較不熟悉的朋友

在設定開機自動啟動v2proxy的時候有發現腳本在各系統架構的有些許不太一樣的語法格式 使用Ubuntu的朋友如果單一執行腳本出現Bad Substitution,請把"{"、"}"改成"("、")"即可

Ubuntu: Create v2panel-stop.sh

#!/bin/sh
PID1=$(cat /var/run/v2ray-admin.pid)
kill -15 $PID1
PID2=$(cat /var/run/v2ray-proxy.pid)
kill -15 $PID2

腳本記得檢查是否有無執行權限,若無執行權限會無法順利執行v2panel.service

climba03003 commented 1 year ago

直接使用 systemctl 管理進程

vi /etc/systemd/system/v2ray-admin.service

[Unit]
Description=V2Ray Admin
After=network.target

[Service]
SuccessExitStatus=143
User=root
Group=root
Type=simple
WorkingDirectory=/opt/jar
ExecStart=/usr/bin/java -jar -Xms40m -Xmx40m -XX:MaxDirectMemorySize=10M -XX:MaxMetaspaceSize=80m admin.jar --spring.config.location=/opt/jar/admin.yaml
ExecStop=/bin/kill -15 $MAINPID

[Install]
WantedBy=multi-user.target

vi /etc/systemd/system/v2ray-proxy.service

[Unit]
Description=V2Ray Proxy
After=network.target

[Service]
SuccessExitStatus=143
User=root
Group=root
Type=simple
WorkingDirectory=/opt/jar
ExecStart=/usr/bin/java -jar -Xms40m -Xmx40m -XX:MaxDirectMemorySize=10M -XX:MaxMetaspaceSize=80m v2ray-proxy.jar --spring.config.location=/opt/jar/proxy.yaml
ExecStop=/bin/kill -15 $MAINPID

[Install]
WantedBy=multi-user.target