-
Notifications
You must be signed in to change notification settings - Fork 439
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
Minor bug fix for shell scripts like kill_tera.sh
, launch_tera.sh
and teracli
#1280
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 如果系统已经预装了readline,就不需要下载此tar包重新编译了 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 已经增加了判断,我的是centos7.2的系统,但是并没有安装readline库。需要手动安装,其他预装库都正常,我认为其他人也会有相似的情况。 |
||
cd ${WORK_DIR} | ||
|
||
######################################## | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
#include <sys/stat.h> | ||
#include <sys/types.h> | ||
#include <unistd.h> | ||
#include <libgen.h> | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. google的代码风格 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 感谢评论,原来我并没有关注过头文件的包含顺序问题,去调查了一下顺序:OS SDK .h , C标准库、C++标准库、其它库的头文件、自己工程的头文件。于是按照这个顺序重新组织了一下,如下: #include "common/file/file_path.h" #include <dirent.h> #include <stdint.h> #include <gflags/gflags.h> #include "common/base/string_ext.h" |
||
#include <gflags/gflags.h> | ||
|
||
|
@@ -105,6 +106,23 @@ bool CreateDirWithRetry(const std::string& dir_path) { | |
} | ||
return is_success; | ||
} | ||
std::string GetCWD(){ | ||
char buf[1024]; | ||
if(getcwd(buf, 1024) == NULL){ | ||
return ""; | ||
} | ||
return buf; | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 代码风格:缩进不对,左大括号缺少空格 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 已修改 |
||
std::string GetProcessDir(){ | ||
char buf[1024]; | ||
ssize_t count = readlink("/proc/self/exe", buf, 1024); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 路径长度最大是1024吗 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 已设置为linux/limits.h中的PATH_MAX常量 |
||
if(count == 0) { | ||
return ""; | ||
} else{ | ||
return dirname(buf); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dirname返回一个char*,是否需要释放;如果不用释放,是否是线程安全的? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 不需要释放,线程安全的。dirname可能返回内部的static alloc的内存,也可能返回buf的内存。buf本身是局部变量,可以确保线程安全,dirname本身是线程安全函数。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 如果是内部的静态分配,为什么是线程安全的 |
||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 同上 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 如上 |
||
std::string UidToName(uid_t uid) { | ||
struct passwd *temp = NULL; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1195,7 +1195,7 @@ static int InitFlags(const std::string& confpath, const std::string& log_prefix) | |
LOG(ERROR) << "should specify no more than one config file"; | ||
return -1; | ||
} | ||
|
||
std::string exedir = GetProcessDir(); | ||
if (!confpath.empty() && IsExist(confpath)){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tera.flag里面会配置logdir,路径不对的话,会导致日志不能输出,可以增加一下判断 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 增加了判断。 |
||
flagfile = confpath; | ||
} else if(!confpath.empty() && !IsExist(confpath)){ | ||
|
@@ -1211,12 +1211,16 @@ 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 { | ||
LOG(ERROR) << "hasn't specify the flagfile, but default config file not found"; | ||
return -1; | ||
} | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 代码风格 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 已修改 |
||
utils::LoadFlagFile(flagfile); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
百度内部编译方式不需要使用此包
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已去掉