loyess / Shell

Shadowsocks with plugins one-click installation. e.g. v2ray-plugin, kcptun, simple-obfs, goquiet, cloak, mos-tls-tunnel, rabbit-tcp, simple-tls, gost-plugin, xray-plugin, qtun, gun
784 stars 357 forks source link

用脚本升级到Shadowsocks rust 1.9.0 出错 #66

Closed windstander closed 3 years ago

windstander commented 3 years ago

实测Lightsail没有问题,Greencloud出错。

root@Server:~# ./ss-plugins.sh restart Stopping Shadowsocks-rust success Stopping ck-server success Starting Shadowsocks-rust success /etc/init.d/shadowsocks-rust: line 130: 1280 Illegal instruction nohup $DAEMON -c $CONF -v > $LOG 2>&1 Starting ck-server success

windstander commented 3 years ago

root@Server:~# ./ss-plugins.sh start Starting Shadowsocks-rust success /etc/init.d/shadowsocks-rust: line 130: 1374 Illegal instruction nohup $DAEMON -c $CONF -v > $LOG 2>&1 ck-server (pid 1300) is already running.

windstander commented 3 years ago

root@Server:~# ./ss-plugins.sh log ———————————————————————————————————————————————————————————— 结束访问:请按Ctrl + C 日志路径:/var/log/shadowsocks-rust.log /var/log/cloak.log ———————————————————————————————————————————————————————————— ==> /var/log/shadowsocks-rust.log <==

==> /var/log/cloak.log <== time="2021-02-21T21:51:13-05:00" level=info msg="Starting standalone mode" time="2021-02-21T21:51:13-05:00" level=info msg="Listening on :80" time="2021-02-21T21:51:13-05:00" level=info msg="Listening on :443"

windstander commented 3 years ago

!/usr/bin/env bash

chkconfig: 2345 90 10

description: A secure socks5 proxy, designed to protect your Internet traffic.

BEGIN INIT INFO

Provides: Shadowsocks-rust

Required-Start: $network $syslog

Required-Stop: $network

Default-Start: 2 3 4 5

Default-Stop: 0 1 6

Short-Description: Fast tunnel proxy that helps you bypass firewalls

Description: Start or stop the Shadowsocks-rust server

END INIT INFO

if [ -f /usr/local/bin/ssserver ]; then DAEMON=/usr/local/bin/ssserver elif [ -f /usr/bin/ssserver ]; then DAEMON=/usr/bin/ssserver fi NAME=Shadowsocks-rust CONF=/etc/shadowsocks/config.json LOG=/var/log/shadowsocks-rust.log PID_DIR=/var/run PID_FILE=$PID_DIR/shadowsocks-rust.pid RET_VAL=0

[ -x $DAEMON ] || exit 0

if [ ! -d "$(dirname ${LOG})" ]; then mkdir -p $(dirname ${LOG}) fi

check_pid(){ get_pid=ps -ef |grep -v grep | grep ssserver |awk '{print $2}' }

check_pid if [ -z $get_pid ]; then if [ -e $PID_FILE ]; then rm -f $PID_FILE fi fi

if [ ! -d $PID_DIR ]; then mkdir -p $PID_DIR if [ $? -ne 0 ]; then echo "Creating PID directory $PID_DIR failed" exit 1 fi fi

if [ ! -f $CONF ]; then echo "$NAME config file $CONF not found" exit 1 fi

check_running() { if [ -e $PID_FILE ]; then if [ -r $PID_FILE ]; then read PID < $PID_FILE if [ -d "/proc/$PID" ]; then return 0 else rm -f $PID_FILE return 1 fi fi else return 2 fi }

do_status() { check_running case $? in 0) echo "$NAME (pid $PID) is running." ;; 1|2) echo "$NAME is stopped" RET_VAL=1 ;; esac }

do_start() { if check_running; then echo "$NAME (pid $PID) is already running." return 0 fi ulimit -n 51200 nohup $DAEMON -c $CONF -v > $LOG 2>&1 & check_pid echo $get_pid > $PID_FILE if check_running; then echo "Starting $NAME success" else echo "Starting $NAME failed" RET_VAL=1 fi }

do_stop() { if check_running; then kill -9 $PID rm -f $PID_FILE echo "Stopping $NAME success" else echo "$NAME is stopped" RET_VAL=1 fi }

do_restart() { do_stop sleep 0.5 do_start }

case "$1" in start|stop|restart|status) do_$1 ;; *) echo "Usage: $0 { start | stop | restart | status }" RET_VAL=1 ;; esac

exit $RET_VAL

查看了启动文件,都是一样的,第130行是esac下面那个空行。

windstander commented 3 years ago

我试了一下,删除93行 nohup $DAEMON -c $CONF -v > $LOG 2>&1 & 就不会报错,但是不能运行成功。

windstander commented 3 years ago

root@Server:~# ssserver -c /etc/shadowsocks/config.json Illegal instruction root@Server:~# ssserver -c /etc/shadowsocks/config.json -d start Illegal instruction

windstander commented 3 years ago

经测试,rust回退到上一个版本就没问题,用1.9.0就不行。可能是这个版本rust和Greencloud不兼容。

loyess commented 3 years ago

下载这个试试:https://github.com/shadowsocks/shadowsocks-rust/releases/download/v1.9.0/shadowsocks-v1.9.0.x86_64-unknown-linux-gnu.tar.xz

如果不行,可能真有问题,因为我测试了两个平台的,一个正常运行,一个和你的情况一样,二进制文件执行会打印 Illegal instruction 。

windstander commented 3 years ago

下载这个试试:https://github.com/shadowsocks/shadowsocks-rust/releases/download/v1.9.0/shadowsocks-v1.9.0.x86_64-unknown-linux-gnu.tar.xz

如果不行,可能真有问题,因为我测试了两个平台的,一个正常运行,一个和你的情况一样,二进制文件执行会打印 Illegal instruction 。

这个手动更新我也试过了,不行。 rust那边给了我回复,

https://github.com/shadowsocks/shadowsocks-rust/issues/426#issuecomment-783292350

说是

Well, your machine is running on a very old CPU, which doesn't support some of the SIMD instruction sets.

Solution:

Compile a ssserver by yourself without the .cargo/config.toml, or compile it with environment variable RUSTFLAGS="-C target-cpu=native" for optimizations for your local CPU.
Get a new server.
windstander commented 3 years ago

怎么办呢?你会不会编译程序,再编译一个ssserver? @loyess

loyess commented 3 years ago

ss-rust 项目主页那有 Build from source 教程,我编译出来的未必适用你的vps。

Use cargo to build. NOTE: RAM >= 2GiB

先去Rust官网根据官方一键安装教程,把Rsut安装上,就可以用cargo去构建了,编译前这个环境变量 export RUSTFLAGS="-C target-cpu=native" 要带上。

loyess commented 3 years ago

ss-rust 的开发者回复你了,你根据他给的步骤编译吧。

loyess commented 3 years ago

我用那台报错 Illegal instruction 的vps编译的,你如果不想自己编译的话,可以试试看。 shadowsocks-v1.9.0.x86_64-unknown-linux-gnu.zip

windstander commented 3 years ago

我用那台报错 Illegal instruction 的vps编译的,你如果不想自己编译的话,可以试试看。 shadowsocks-v1.9.0.x86_64-unknown-linux-gnu.zip

谢谢,我试了可以用,但还是自己想试着编译一下。

作者说:

Install Docker
Remove this file: .cargo/config.toml, or just remove the instruction sets that your CPU doesn't support, maybe sse4.*, avx, ...
Install Rust's toolchain: https://rustup.rs/
Install Cross: cargo install cross
Run:

cd build
./build-release -t "x86_64-unknown-linux-gnu"

Replace the -t target with your platform's specific value.
You will see release packages in build/release

我已经走到BUILD这一步了,不知道怎么弄。是不是要去rust主页把源码整个下载了,再把那个zip解压到服务器的root文件夹,再运行build命令?

loyess commented 3 years ago

对的,下载 Releases 页面的 Source code 压缩包 然后解压,或者用git clone 也行。

windstander commented 3 years ago

对的,下载 Releases 页面的 Source code 压缩包 然后解压,或者用git clone 也行。

哈哈,我也弄好了,就是把root文件夹弄得有点乱。要是可以不放根目录就好了。

windstander commented 3 years ago

源码必须放root文件夹,不能单独放一个文件夹进行安装吗?那样安装好以后方便整个删除。

loyess commented 3 years ago

可以单独放一个文件夹编译,自己记得就行!

loyess commented 3 years ago

Shadowsocks-rust v1.9.1 以解决此问题。

参考:

Release v1.9.1

1.9.0 无法在Greencloud正常运行 #426

remote AVX for compatibility of Intel based routers

windstander commented 3 years ago

Shadowsocks-rust v1.9.1 以解决此问题。

参考:

Release v1.9.1

1.9.0 无法在Greencloud正常运行 #426

remote AVX for compatibility of Intel based routers

谢谢提醒,我也订阅了更新,已经用上了。