diff --git a/build.conf.template b/build.conf.template index b34741068..09edc8462 100755 --- a/build.conf.template +++ b/build.conf.template @@ -18,6 +18,7 @@ LIBUNWIND_VERSION=0.99 GPERFTOOLS_VERSION=2.5 INS_VERSION=0.15 NOSE_VERSION=1.3.7 +READLINE_VERSION=7.0 if [ $MIRROR == "china" ]; then BOOST_URL=http://mirrors.tuna.tsinghua.edu.cn/macports/distfiles/boost/boost_${BOOST_VERSION}.tar.bz2 @@ -32,6 +33,7 @@ if [ $MIRROR == "china" ]; then GPERFTOOLS_URL=https://github.com/00k/gperftools/raw/master/gperftools-${GPERFTOOLS_VERSION}.tar.gz INS_URL=https://github.com/baidu/ins/archive/${INS_VERSION}.tar.gz NOSE_URL=http://mirrors.163.com/gentoo/distfiles/nose-${NOSE_VERSION}.tar.gz + READLINE_URL=http://git.savannah.gnu.org/cgit/readline.git/snapshot/readline-${READLINE_VERSION}.tar.gz elif [ $MIRROR == "origin" ]; then BOOST_URL=http://downloads.sourceforge.net/project/boost/boost/1.58.0/boost_${BOOST_VERSION}.tar.bz2 PROTOBUF_URL=https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/protobuf-${PROTOBUF_VERSION}.tar.bz2 @@ -45,6 +47,7 @@ elif [ $MIRROR == "origin" ]; then GPERFTOOLS_URL=https://github.com/gperftools/gperftools/releases/download/gperftools-${GPERFTOOLS_VERSION}/gperftools-${GPERFTOOLS_VERSION}.tar.gz INS_URL=https://github.com/baidu/ins/archive/${INS_VERSION}.tar.gz NOSE_URL=https://pypi.python.org/packages/58/a5/0dc93c3ec33f4e281849523a5a913fa1eea9a3068acfa754d44d88107a44/nose-${NOSE_VERSION}.tar.gz + READLINE_URL=http://git.savannah.gnu.org/cgit/readline.git/snapshot/readline-${READLINE_VERSION}.tar.gz elif [ $MIRROR == "baidu" ]; then BOOST_URL=http://gitlab.baidu.com/baidups/third/raw/master/boost_${BOOST_VERSION}.tar.bz2 PROTOBUF_URL=http://gitlab.baidu.com/baidups/third/raw/master/protobuf-${PROTOBUF_VERSION}.tar.bz2 diff --git a/build.sh b/build.sh index 5283ba2fc..e35ab3ad3 100755 --- a/build.sh +++ b/build.sh @@ -223,7 +223,7 @@ if [ ${NOSE_VERSION} == "DISABLE" ]; then echo "Disable nose." elif [ ! -f "${FLAG_DIR}/nose_${NOSE_VERSION}" ] \ || [ ! -f "${DEPS_PREFIX}/bin/nosetests" ] \ - || [ ! -d "${DEPS_PREFIX}/lib/nose" ]; then + || [ ! -d "${DEPS_PREFIX}/lib/"nose* ]; then wget --no-check-certificate -O nose-${NOSE_VERSION}.tar.gz ${NOSE_URL} tar zxf nose-${NOSE_VERSION}.tar.gz --recursive-unlink cd nose-${NOSE_VERSION} @@ -233,6 +233,21 @@ elif [ ! -f "${FLAG_DIR}/nose_${NOSE_VERSION}" ] \ touch "${FLAG_DIR}/nose_${NOSE_VERSION}" fi +# readline (teracli_main.cc use this and lead to compile failed) +if [ ${READLINE_VERSION} == "DISABLE" ]; then + echo "Disable readline." +elif [ ! -f "${FLAG_DIR}/readline_${READLINE_VERSION}" ] \ + || [ ! -f "${DEPS_PREFIX}/lib/libreadline.a" ] \ + || [ ! -d "${DEPS_PREFIX}/include/readline" ]; then + wget --no-check-certificate -O readline-${READLINE_VERSION}.tar.gz ${READLINE_URL} + tar zxf readline-${READLINE_VERSION}.tar.gz --recursive-unlink + cd readline-${READLINE_VERSION} + ./configure ${DEPS_CONFIG} CPPFLAGS=-I${DEPS_PREFIX}/include LDFLAGS=-L${DEPS_PREFIX}/lib + make install + cd - + touch "${FLAG_DIR}/readline_${READLINE_VERSION}" +fi + cd ${WORK_DIR} ######################################## diff --git a/example/onebox/bin/kill_tera.sh b/example/onebox/bin/kill_tera.sh index 047de86bb..9f1a9ea0f 100755 --- a/example/onebox/bin/kill_tera.sh +++ b/example/onebox/bin/kill_tera.sh @@ -1,5 +1,6 @@ #!/bin/bash -source ./config +CURRENT_DIR=`dirname $0` +source ${CURRENT_DIR}/config PID=`ps x | grep tera_master | grep $PORT | awk '{print $1}'`; if [ ${PID}"x" != "x" ]; then diff --git a/example/onebox/bin/launch_tera.sh b/example/onebox/bin/launch_tera.sh index c6d5f2fba..bc3d22956 100755 --- a/example/onebox/bin/launch_tera.sh +++ b/example/onebox/bin/launch_tera.sh @@ -3,7 +3,7 @@ CURRENT_DIR=`dirname $0` source ${CURRENT_DIR}/config # make sure tera is killed -./kill_tera.sh +./$CURRENT_DIR/kill_tera.sh FAKE_ZK_PATH_PREFIX="${CURRENT_DIR}/../fakezk" TIME=`date +%Y-%m-%d-%H:%M:%S` diff --git a/src/common/file/file_path.cc b/src/common/file/file_path.cc index 44738117f..cc1a83d2d 100644 --- a/src/common/file/file_path.cc +++ b/src/common/file/file_path.cc @@ -2,21 +2,26 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "common/file/file_path.h" + #include #include +#include +#include #include +#include +#include +#include + #include #include #include #include -#include -#include -#include #include #include "common/base/string_ext.h" -#include "common/file/file_path.h" + DECLARE_int32(file_op_retry_times); @@ -105,6 +110,23 @@ bool CreateDirWithRetry(const std::string& dir_path) { } return is_success; } +std::string GetCWD() { + char buf[PATH_MAX]; + if(getcwd(buf, PATH_MAX) == NULL){ + return ""; + } + return buf; +} + +std::string GetProcessDir() { + char buf[PATH_MAX]; + ssize_t count = readlink("/proc/self/exe", buf, PATH_MAX); + if(count == 0) { + return ""; + } else{ + return dirname(buf); + } +} std::string UidToName(uid_t uid) { struct passwd *temp = NULL; diff --git a/src/common/file/file_path.h b/src/common/file/file_path.h index e0ab5d002..819581441 100644 --- a/src/common/file/file_path.h +++ b/src/common/file/file_path.h @@ -21,6 +21,9 @@ std::string GetPathPrefix(const std::string& full_path, bool CreateDirWithRetry(const std::string& dir_path); +std::string GetCWD(); +std::string GetProcessDir(); + std::string GidToName(gid_t gid); std::string UidToName(uid_t uid); diff --git a/src/sdk/client_impl.cc b/src/sdk/client_impl.cc index bc9eb1998..f510f0bce 100644 --- a/src/sdk/client_impl.cc +++ b/src/sdk/client_impl.cc @@ -1189,13 +1189,13 @@ static int SpecifiedFlagfileCount(const std::string& confpath) { static int InitFlags(const std::string& confpath, const std::string& log_prefix) { // search conf file, priority: - // user-specified > ./tera.flag > ../conf/tera.flag + // user-specified > ./tera.flag > ../conf/tera.flag > exeDir/tera.flag > exeDir/../tera.flag std::string flagfile; if (SpecifiedFlagfileCount(confpath) > 1) { LOG(ERROR) << "should specify no more than one config file"; return -1; } - + std::string exedir = GetProcessDir(); if (!confpath.empty() && IsExist(confpath)){ flagfile = confpath; } else if(!confpath.empty() && !IsExist(confpath)){ @@ -1211,6 +1211,10 @@ static int InitFlags(const std::string& confpath, const std::string& log_prefix) flagfile = "./tera.flag"; } else if (IsExist("../conf/tera.flag")) { flagfile = "../conf/tera.flag"; + } else if (IsExist(exedir + "/./tera.flag")) { + flagfile = exedir + "/./tera.flag"; + } else if (IsExist(exedir + "/../conf/tera.flag")) { + flagfile = exedir + "/../conf/tera.flag"; } else if (IsExist(utils::GetValueFromEnv("TERA_CONF"))) { flagfile = utils::GetValueFromEnv("TERA_CONF"); } else { @@ -1220,6 +1224,11 @@ static int InitFlags(const std::string& confpath, const std::string& log_prefix) utils::LoadFlagFile(flagfile); + if(!IsDir(FLAGS_log_dir)) { + LOG(ERROR) << "wrong log directory: "<