1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

support change work_dir for oryx.

This commit is contained in:
winlin 2016-09-23 14:53:58 +08:00
parent 9bd2ff16e2
commit 2a01540433
5 changed files with 31 additions and 1 deletions

View file

@ -343,6 +343,7 @@ Remark:
## History ## History
* v2.0, 2016-09-23, support change work_dir for oryx.
* v2.0, 2016-09-15, fix #640, typo for rtmp type. 2.0.217 * v2.0, 2016-09-15, fix #640, typo for rtmp type. 2.0.217
* v2.0, 2016-09-12, fix fast stream error bug. 2.0.216 * v2.0, 2016-09-12, fix fast stream error bug. 2.0.216
* <strong>v2.0, 2016-09-09, [2.0 beta1(2.0.215)][r2.0b1] released. 89941 lines.</strong> * <strong>v2.0, 2016-09-09, [2.0 beta1(2.0.215)][r2.0b1] released. 89941 lines.</strong>

View file

@ -50,6 +50,12 @@ daemon on;
# default: off # default: off
utc_time off; utc_time off;
# the work dir for server, to chdir(work_dir) when not empty or "./"
# user can config this directory to change the dir.
# @reamrk do not support reload.
# default: ./
work_dir ./;
############################################################################################# #############################################################################################
# heartbeat/stats sections # heartbeat/stats sections
############################################################################################# #############################################################################################

View file

@ -1567,7 +1567,7 @@ int SrsConfig::check_config()
&& n != "max_connections" && n != "daemon" && n != "heartbeat" && n != "max_connections" && n != "daemon" && n != "heartbeat"
&& n != "http_api" && n != "stats" && n != "vhost" && n != "pithy_print_ms" && n != "http_api" && n != "stats" && n != "vhost" && n != "pithy_print_ms"
&& n != "http_stream" && n != "http_server" && n != "stream_caster" && n != "http_stream" && n != "http_server" && n != "stream_caster"
&& n != "utc_time" && n != "utc_time" && n != "work_dir"
) { ) {
ret = ERROR_SYSTEM_CONFIG_INVALID; ret = ERROR_SYSTEM_CONFIG_INVALID;
srs_error("unsupported directive %s, ret=%d", n.c_str(), ret); srs_error("unsupported directive %s, ret=%d", n.c_str(), ret);
@ -2172,6 +2172,17 @@ bool SrsConfig::get_utc_time()
return SRS_CONF_PERFER_FALSE(conf->arg0()); return SRS_CONF_PERFER_FALSE(conf->arg0());
} }
string SrsConfig::get_work_dir() {
static string DEFAULT = "./";
SrsConfDirective* conf = root->get("work_dir");
if( !conf || conf->arg0().empty()) {
return DEFAULT;
}
return conf->arg0();
}
vector<SrsConfDirective*> SrsConfig::get_stream_casters() vector<SrsConfDirective*> SrsConfig::get_stream_casters()
{ {
srs_assert(root); srs_assert(root);

View file

@ -374,6 +374,11 @@ public:
* whether use utc-time to format the time. * whether use utc-time to format the time.
*/ */
virtual bool get_utc_time(); virtual bool get_utc_time();
/**
* get the configed work dir.
* ignore if empty string.
*/
virtual std::string get_work_dir();
// stream_caster section // stream_caster section
public: public:
/** /**

View file

@ -282,6 +282,13 @@ int main(int argc, char** argv)
return ret; return ret;
} }
// change the work dir and set cwd.
std::string cwd = _srs_config->get_work_dir();
if (!cwd.empty() && cwd != "./" && (ret = chdir(cwd.c_str())) != ERROR_SUCCESS) {
srs_error("change cwd to %s failed. ret=%d", cwd.c_str(), ret);
return ret;
}
// config parsed, initialize log. // config parsed, initialize log.
if ((ret = _srs_log->initialize()) != ERROR_SUCCESS) { if ((ret = _srs_log->initialize()) != ERROR_SUCCESS) {
return ret; return ret;