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

使用maven package打包后无法执行脚本错误:./startup.sh: bad interpreter: /bin/bash^M: no such file or directory #13

Closed
yoqu opened this issue Sep 16, 2017 · 7 comments

Comments

@yoqu
Copy link

yoqu commented Sep 16, 2017

./startup.sh: bad interpreter: /bin/bash^M: no such file or directory

打包后在distribution的proxy-server中,执行startup.sh脚本报错。脚本内容为:

#!/bin/bash
cd `dirname $0`
cd ..
DEPLOY_DIR=`pwd`
CONF_DIR=$DEPLOY_DIR/conf
LOGS_DIR=$DEPLOY_DIR/logs

APP_MAINCLASS=org.fengfei.lanproxy.server.ProxyServerContainer

PIDS=`ps -ef | grep java | grep "$CONF_DIR" |awk '{print $2}'`
if [ -n "$PIDS" ]; then
    echo "ERROR: already started!"
    echo "PID: $PIDS"
    exit 1
fi

if [ ! -d $LOGS_DIR ]; then
    mkdir $LOGS_DIR
fi
STDOUT_FILE=$LOGS_DIR/stdout.log
CLOG_FILE=$LOGS_DIR/gc.log

LIB_DIR=$DEPLOY_DIR/lib
LIB_JARS=`ls $LIB_DIR|grep .jar|awk '{print "'$LIB_DIR'/"$0}'| xargs | sed "s/ /:/g"`

JAVA_OPTS=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true "
JAVA_DEBUG_OPTS=""
if [ "$1" = "debug" ]; then
    JAVA_DEBUG_OPTS=" -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n "
fi
JAVA_JMX_OPTS=""
if [ "$1" = "jmx" ]; then
    JAVA_JMX_OPTS=" -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false "
fi
JAVA_MEM_OPTS=""
#JAVA_MEM_OPTS="-server -Xms5120M -Xmx5120M -Xmn1024M -Xnoclassgc -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:+CMSParallelRemarkEnabled -XX:CMSInitiatingOccupancyFraction=80 -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+PrintClassHistogram -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC -Xloggc:$CLOG_FILE"
echo -e "Starting the proxy server ...\c"
nohup java -Dapp.home=$DEPLOY_DIR $JAVA_OPTS $JAVA_MEM_OPTS $JAVA_DEBUG_OPTS $JAVA_JMX_OPTS -classpath $CONF_DIR:$LIB_JARS $APP_MAINCLASS >$STDOUT_FILE 2>&1 &
sleep 1
echo "started"
PIDS=`ps -ef | grep java | grep "$DEPLOY_DIR" | awk '{print $2}'`
echo "PID: $PIDS"
@towerhe
Copy link

towerhe commented Sep 16, 2017

你检查一下/bin/bash是否存在,根据你提示的错误应该是没有bash

@yoqu
Copy link
Author

yoqu commented Sep 16, 2017

已经检查过了,没有问题,我下载你打好的包就不会有问题,但是我自己用maven打的包有这个bug,可能是你提交最新代码时候更新了脚本吧?
另外还有个bug就是在后台管理界面添加端口配置js报错了,实际上是保存成功了,应该是回调jschu处理产生了bug。
image

@ffay
Copy link
Owner

ffay commented Sep 16, 2017

./startup.sh: bad interpreter: /bin/bash^M: no such file or directory

是不是在windows上编译的?可能windows上编译的在linux上运行会有问题,可以直接把bin目录下的脚本换成resources里面的脚本就ok了,后续我跟踪解决下这个问题

js报错的问题已解决

@yoqu
Copy link
Author

yoqu commented Sep 17, 2017

对,windows编译的,但是脚本跟在哪个os编译的没关系吧,我看你脚本都是预先写好的,编译后copy到bin目录的

@towerhe
Copy link

towerhe commented Sep 18, 2017

建议将所有的换行符换成linux的试一试,我在mac上面打包是没有问题的。

@qfrank
Copy link

qfrank commented Oct 13, 2017

^M .. 初看很像win系统与linux系统换行符不一样导致的

@yoqu
Copy link
Author

yoqu commented Oct 13, 2017

对,换行符问题。
东西很好,正在使用中,支持作者。
另外作者有没有qq群?表示有想法一起协作开发一些功能。

@yoqu yoqu closed this as completed Oct 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants