|
|
@ -52,6 +52,7 @@ using namespace std;
|
|
|
|
int run(SrsServer* svr);
|
|
|
|
int run(SrsServer* svr);
|
|
|
|
int run_master(SrsServer* svr);
|
|
|
|
int run_master(SrsServer* svr);
|
|
|
|
void show_macro_features();
|
|
|
|
void show_macro_features();
|
|
|
|
|
|
|
|
string srs_getenv(const char* name);
|
|
|
|
|
|
|
|
|
|
|
|
// @global log and context.
|
|
|
|
// @global log and context.
|
|
|
|
ISrsLog* _srs_log = new SrsFastLog();
|
|
|
|
ISrsLog* _srs_log = new SrsFastLog();
|
|
|
@ -127,23 +128,45 @@ int main(int argc, char** argv)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
srs_trace("cwd=%s, work_dir=%s", _srs_config->cwd().c_str(), cwd.c_str());
|
|
|
|
srs_trace("cwd=%s, work_dir=%s", _srs_config->cwd().c_str(), cwd.c_str());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// for memory check or detect.
|
|
|
|
|
|
|
|
if (true) {
|
|
|
|
|
|
|
|
stringstream ss;
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef SRS_PERF_GLIBC_MEMORY_CHECK
|
|
|
|
#ifdef SRS_PERF_GLIBC_MEMORY_CHECK
|
|
|
|
// ensure glibc write error to stderr.
|
|
|
|
// ensure glibc write error to stderr.
|
|
|
|
|
|
|
|
string lfsov = srs_getenv("LIBC_FATAL_STDERR_");
|
|
|
|
setenv("LIBC_FATAL_STDERR_", "1", 1);
|
|
|
|
setenv("LIBC_FATAL_STDERR_", "1", 1);
|
|
|
|
|
|
|
|
string lfsnv = srs_getenv("LIBC_FATAL_STDERR_");
|
|
|
|
|
|
|
|
//
|
|
|
|
// ensure glibc to do alloc check.
|
|
|
|
// ensure glibc to do alloc check.
|
|
|
|
|
|
|
|
string mcov = srs_getenv("MALLOC_CHECK_");
|
|
|
|
setenv("MALLOC_CHECK_", "1", 1);
|
|
|
|
setenv("MALLOC_CHECK_", "1", 1);
|
|
|
|
srs_trace("env MALLOC_CHECK_=1 LIBC_FATAL_STDERR_=1");
|
|
|
|
string mcnv = srs_getenv("MALLOC_CHECK_");
|
|
|
|
|
|
|
|
ss << "glic mem-check env MALLOC_CHECK_ " << mcov << "=>" << mcnv << ", LIBC_FATAL_STDERR_ " << lfsov << "=>" << lfsnv << ".";
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef SRS_AUTO_GPERF_MC
|
|
|
|
|
|
|
|
string hcov = srs_getenv("HEAPCHECK");
|
|
|
|
|
|
|
|
if (hcov.empty()) {
|
|
|
|
|
|
|
|
string cpath = _srs_config->config();
|
|
|
|
|
|
|
|
srs_warn("gmc HEAPCHECK is required, for example: env HEAPCHECK=normal ./objs/srs -c %s", cpath.c_str());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
ss << "gmc env HEAPCHECK=" << hcov << ".";
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef SRS_AUTO_GPERF_MD
|
|
|
|
#ifdef SRS_AUTO_GPERF_MD
|
|
|
|
char* TCMALLOC_PAGE_FENCE = getenv("TCMALLOC_PAGE_FENCE");
|
|
|
|
char* TCMALLOC_PAGE_FENCE = getenv("TCMALLOC_PAGE_FENCE");
|
|
|
|
if (!TCMALLOC_PAGE_FENCE || strcmp(TCMALLOC_PAGE_FENCE, "1")) {
|
|
|
|
if (!TCMALLOC_PAGE_FENCE || strcmp(TCMALLOC_PAGE_FENCE, "1")) {
|
|
|
|
srs_trace("gmd enabled without env TCMALLOC_PAGE_FENCE=1");
|
|
|
|
srs_warn("gmd enabled without env TCMALLOC_PAGE_FENCE=1");
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
srs_trace("env TCMALLOC_PAGE_FENCE=1");
|
|
|
|
ss << "gmd env TCMALLOC_PAGE_FENCE=" << TCMALLOC_PAGE_FENCE << ".";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
srs_trace(ss.str().c_str());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// we check the config when the log initialized.
|
|
|
|
// we check the config when the log initialized.
|
|
|
|
if ((ret = _srs_config->check_config()) != ERROR_SUCCESS) {
|
|
|
|
if ((ret = _srs_config->check_config()) != ERROR_SUCCESS) {
|
|
|
|
return ret;
|
|
|
|
return ret;
|
|
|
@ -330,6 +353,17 @@ void show_macro_features()
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string srs_getenv(const char* name)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
char* cv = ::getenv(name);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (cv) {
|
|
|
|
|
|
|
|
return cv;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return "";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int run(SrsServer* svr)
|
|
|
|
int run(SrsServer* svr)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// if not deamon, directly run master.
|
|
|
|
// if not deamon, directly run master.
|
|
|
|