1.add more information for command info and config get

2.fix log file symbol link error
This commit is contained in:
fortrue 2017-12-26 14:27:09 +08:00
parent bd9d2ed57e
commit 45661645ed
2 changed files with 13 additions and 5 deletions

View File

@ -899,7 +899,8 @@ void Handler::infoRequest(Request* req, const String& key)
#define Scope(all, empty, header) ((all || empty || key.equal(header, true)) ? \ #define Scope(all, empty, header) ((all || empty || key.equal(header, true)) ? \
(buf = buf->fappend("# %s\n", header)) : nullptr) (buf = buf->fappend("# %s\n", header)) : nullptr)
if (Scope(all, empty, "Proxy")) { if (all || empty || key.equal("Proxy", true) || key.equal("Server", true)) {
buf = buf->fappend("# %s\n", "Proxy");
buf = buf->fappend("Version:%s\n", _PREDIXY_VERSION_); buf = buf->fappend("Version:%s\n", _PREDIXY_VERSION_);
buf = buf->fappend("Name:%s\n", mProxy->conf()->name()); buf = buf->fappend("Name:%s\n", mProxy->conf()->name());
buf = buf->fappend("Bind:%s\n", mProxy->conf()->bind()); buf = buf->fappend("Bind:%s\n", mProxy->conf()->bind());
@ -1196,6 +1197,11 @@ void Handler::configGetRequest(Request* req)
} }
do { do {
Append("Name", "%s", conf->name());
Append("Bind", "%s", conf->bind());
Append("WorkerThreads", "%d", conf->workerThreads());
Append("BufSize", "%d", Buffer::getSize());
Append("LocalDC", "%s", conf->localDC().c_str());
Append("MaxMemory", "%ld", AllocBase::getMaxMemory()); Append("MaxMemory", "%ld", AllocBase::getMaxMemory());
Append("ClientTimeout", "%d", conf->clientTimeout() / 1000000); Append("ClientTimeout", "%d", conf->clientTimeout() / 1000000);
Append("AllowMissLog", "%s", log->allowMissLog() ? "true" : "false"); Append("AllowMissLog", "%s", log->allowMissLog() ? "true" : "false");

View File

@ -118,7 +118,9 @@ bool LogFileSink::reopen(time_t t)
} }
if (mFileSuffixFmt) { if (mFileSuffixFmt) {
unlink(mFileName.c_str()); unlink(mFileName.c_str());
if (symlink(mFilePath, mFileName.c_str()) == -1) { const char* name = strrchr(mFilePath, '/');
name = name ? name + 1 : mFilePath;
if (symlink(name, mFileName.c_str()) == -1) {
fprintf(stderr, "create symbol link for %s fail", mFileName.c_str()); fprintf(stderr, "create symbol link for %s fail", mFileName.c_str());
} }
} }
@ -135,10 +137,10 @@ bool LogFileSink::setFile(const char* path, int rotateSecs, long rotateBytes)
if (len > 4 && strcasecmp(path + len - 4, ".log") == 0) { if (len > 4 && strcasecmp(path + len - 4, ".log") == 0) {
len -= 4; len -= 4;
} }
}
if (len + FileSuffixReserveLen >= MaxPathLen) { if (len + FileSuffixReserveLen >= MaxPathLen) {
return false; return false;
} }
}
mFileName = path; mFileName = path;
mFilePathLen = len; mFilePathLen = len;
memcpy(mFilePath, path, len); memcpy(mFilePath, path, len);