mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
support dolphin
This commit is contained in:
parent
e5461d2df9
commit
394e070b2e
3 changed files with 63 additions and 2 deletions
|
@ -364,6 +364,8 @@ int SrsConfDirective::read_token(SrsConfigBuffer* buffer, vector<string>& args,
|
|||
|
||||
SrsConfig::SrsConfig()
|
||||
{
|
||||
dolphin = false;
|
||||
|
||||
show_help = false;
|
||||
show_version = false;
|
||||
test_conf = false;
|
||||
|
@ -378,6 +380,25 @@ SrsConfig::~SrsConfig()
|
|||
srs_freep(root);
|
||||
}
|
||||
|
||||
bool SrsConfig::is_dolphin()
|
||||
{
|
||||
return dolphin;
|
||||
}
|
||||
|
||||
void SrsConfig::set_config_directive(SrsConfDirective* parent, string dir, string value)
|
||||
{
|
||||
SrsConfDirective* d = parent->get(dir);
|
||||
|
||||
if (!d) {
|
||||
d = new SrsConfDirective();
|
||||
d->name = dir;
|
||||
parent->directives.push_back(d);
|
||||
}
|
||||
|
||||
d->args.clear();
|
||||
d->args.push_back(value);
|
||||
}
|
||||
|
||||
void SrsConfig::subscribe(ISrsReloadHandler* handler)
|
||||
{
|
||||
std::vector<ISrsReloadHandler*>::iterator it;
|
||||
|
@ -1260,6 +1281,19 @@ int SrsConfig::parse_argv(int& i, char** argv)
|
|||
show_help = false;
|
||||
test_conf = true;
|
||||
break;
|
||||
case 'p':
|
||||
dolphin = true;
|
||||
if (*p) {
|
||||
dolphin_port = p;
|
||||
continue;
|
||||
}
|
||||
if (argv[++i]) {
|
||||
dolphin_port = argv[i];
|
||||
continue;
|
||||
}
|
||||
ret = ERROR_SYSTEM_CONFIG_INVALID;
|
||||
srs_error("option \"-p\" requires params, ret=%d", ret);
|
||||
return ret;
|
||||
case 'v':
|
||||
case 'V':
|
||||
show_help = false;
|
||||
|
@ -1269,11 +1303,11 @@ int SrsConfig::parse_argv(int& i, char** argv)
|
|||
show_help = false;
|
||||
if (*p) {
|
||||
config_file = p;
|
||||
return ret;
|
||||
continue;
|
||||
}
|
||||
if (argv[++i]) {
|
||||
config_file = argv[i];
|
||||
return ret;
|
||||
continue;
|
||||
}
|
||||
ret = ERROR_SYSTEM_CONFIG_INVALID;
|
||||
srs_error("option \"-c\" requires parameter, ret=%d", ret);
|
||||
|
@ -1844,6 +1878,14 @@ int SrsConfig::parse_buffer(SrsConfigBuffer* buffer)
|
|||
if ((ret = root->parse(buffer)) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
// mock by dolphin mode.
|
||||
// for the dolphin will start srs with specified params.
|
||||
if (dolphin) {
|
||||
set_config_directive(root, "listen", dolphin_port);
|
||||
set_config_directive(root, "daemon", "off");
|
||||
set_config_directive(root, "srs_log_tank", "console");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -266,6 +266,12 @@ class SrsConfig
|
|||
{
|
||||
// user command
|
||||
private:
|
||||
/**
|
||||
* whether srs is run in dolphin mode.
|
||||
* @see https://github.com/simple-rtmp-server/srs-dolphin
|
||||
*/
|
||||
bool dolphin;
|
||||
std::string dolphin_port;
|
||||
/**
|
||||
* whether show help and exit.
|
||||
*/
|
||||
|
@ -309,6 +315,14 @@ private:
|
|||
public:
|
||||
SrsConfig();
|
||||
virtual ~SrsConfig();
|
||||
// dolphin
|
||||
public:
|
||||
/**
|
||||
* whether srs is in dolphin mode.
|
||||
*/
|
||||
virtual bool is_dolphin();
|
||||
private:
|
||||
virtual void set_config_directive(SrsConfDirective* parent, std::string dir, std::string value);
|
||||
// reload
|
||||
public:
|
||||
/**
|
||||
|
|
|
@ -639,6 +639,11 @@ int SrsServer::acquire_pid_file()
|
|||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
// when srs in dolphin mode, no need the pid file.
|
||||
if (_srs_config->is_dolphin()) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string pid_file = _srs_config->get_pid_file();
|
||||
|
||||
// -rw-r--r--
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue