mirror of
https://github.com/ossrs/srs.git
synced 2025-02-15 04:42:04 +00:00
update the cwd
This commit is contained in:
parent
07fe35f11d
commit
3659eec9d1
3 changed files with 23 additions and 6 deletions
|
@ -1339,11 +1339,6 @@ int SrsConfig::parse_options(int argc, char** argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// cwd
|
|
||||||
char cwd[256];
|
|
||||||
getcwd(cwd, sizeof(cwd));
|
|
||||||
_cwd = cwd;
|
|
||||||
|
|
||||||
// config
|
// config
|
||||||
show_help = true;
|
show_help = true;
|
||||||
for (int i = 1; i < argc; i++) {
|
for (int i = 1; i < argc; i++) {
|
||||||
|
@ -1411,6 +1406,18 @@ int SrsConfig::parse_options(int argc, char** argv)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int SrsConfig::initialize_cwd()
|
||||||
|
{
|
||||||
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
|
// cwd
|
||||||
|
char cwd[256];
|
||||||
|
getcwd(cwd, sizeof(cwd));
|
||||||
|
_cwd = cwd;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
string SrsConfig::config()
|
string SrsConfig::config()
|
||||||
{
|
{
|
||||||
return config_file;
|
return config_file;
|
||||||
|
|
|
@ -287,6 +287,11 @@ public:
|
||||||
* parse the cli, the main(argc,argv) function.
|
* parse the cli, the main(argc,argv) function.
|
||||||
*/
|
*/
|
||||||
virtual int parse_options(int argc, char** argv);
|
virtual int parse_options(int argc, char** argv);
|
||||||
|
/**
|
||||||
|
* initialize the cwd for server,
|
||||||
|
* because we may change the workdir.
|
||||||
|
*/
|
||||||
|
virtual int initialize_cwd();
|
||||||
/**
|
/**
|
||||||
* get the config file path.
|
* get the config file path.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -34,6 +34,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
#include <gperftools/profiler.h>
|
#include <gperftools/profiler.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
#include <srs_kernel_error.hpp>
|
#include <srs_kernel_error.hpp>
|
||||||
#include <srs_app_server.hpp>
|
#include <srs_app_server.hpp>
|
||||||
#include <srs_app_config.hpp>
|
#include <srs_app_config.hpp>
|
||||||
|
@ -283,11 +285,14 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
// change the work dir and set cwd.
|
// change the work dir and set cwd.
|
||||||
std::string cwd = _srs_config->get_work_dir();
|
string cwd = _srs_config->get_work_dir();
|
||||||
if (!cwd.empty() && cwd != "./" && (ret = chdir(cwd.c_str())) != ERROR_SUCCESS) {
|
if (!cwd.empty() && cwd != "./" && (ret = chdir(cwd.c_str())) != ERROR_SUCCESS) {
|
||||||
srs_error("change cwd to %s failed. ret=%d", cwd.c_str(), ret);
|
srs_error("change cwd to %s failed. ret=%d", cwd.c_str(), ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
if ((ret = _srs_config->initialize_cwd()) != ERROR_SUCCESS) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// config parsed, initialize log.
|
// config parsed, initialize log.
|
||||||
if ((ret = _srs_log->initialize()) != ERROR_SUCCESS) {
|
if ((ret = _srs_log->initialize()) != ERROR_SUCCESS) {
|
||||||
|
|
Loading…
Reference in a new issue