mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
refine the max connections, compare the system ulimit max open files, error when exeed limit
This commit is contained in:
parent
5f7ff37e64
commit
ebf9e560b1
24 changed files with 133 additions and 4 deletions
|
@ -2,6 +2,7 @@
|
|||
# @see full.conf for detail config.
|
||||
|
||||
listen 1935;
|
||||
max_connections 1000;
|
||||
vhost __defaultVhost__ {
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# @see full.conf for detail config.
|
||||
|
||||
listen 1935;
|
||||
max_connections 1000;
|
||||
daemon off;
|
||||
srs_log_tank console;
|
||||
http_api {
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
# @see full.conf for detail config.
|
||||
|
||||
listen 19350;
|
||||
max_connections 1000;
|
||||
daemon on;
|
||||
srs_log_tank file;
|
||||
srs_log_file ./objs/srs.demo.19350.log;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
# @see full.conf for detail config.
|
||||
|
||||
listen 1935;
|
||||
max_connections 1000;
|
||||
daemon on;
|
||||
srs_log_tank file;
|
||||
srs_log_file ./objs/srs.demo.log;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
# @see full.conf for detail config.
|
||||
|
||||
listen 1935;
|
||||
max_connections 1000;
|
||||
vhost __defaultVhost__ {
|
||||
dvr {
|
||||
enabled on;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
# @see full.conf for detail config.
|
||||
|
||||
listen 1935;
|
||||
max_connections 1000;
|
||||
vhost __defaultVhost__ {
|
||||
dvr {
|
||||
enabled on;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
# @see full.conf for detail config.
|
||||
|
||||
listen 1935;
|
||||
max_connections 1000;
|
||||
pid objs/edge.pid;
|
||||
srs_log_file ./objs/edge.log;
|
||||
vhost __defaultVhost__ {
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
# @see https://github.com/winlinvip/simple-rtmp-server/wiki/DRM
|
||||
# @see full.conf for detail config.
|
||||
|
||||
listen 1935;
|
||||
listen 1935
|
||||
max_connections 1000;
|
||||
vhost __defaultVhost__ {
|
||||
mode remote;
|
||||
origin 127.0.0.1:19350;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
# @see full.conf for detail config.
|
||||
|
||||
listen 1935;
|
||||
max_connections 1000;
|
||||
vhost __defaultVhost__ {
|
||||
transcode {
|
||||
enabled on;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
# @see full.conf for detail config.
|
||||
|
||||
listen 1935;
|
||||
max_connections 1000;
|
||||
pid ./objs/srs.master.pid;
|
||||
srs_log_tank file;
|
||||
srs_log_file ./objs/srs.master.log;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
# @see full.conf for detail config.
|
||||
|
||||
listen 19350;
|
||||
max_connections 1000;
|
||||
pid ./objs/srs.slave.pid;
|
||||
srs_log_tank file;
|
||||
srs_log_file ./objs/srs.slave.log;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
# @see full.conf for detail config.
|
||||
|
||||
listen 1935;
|
||||
max_connections 1000;
|
||||
vhost __defaultVhost__ {
|
||||
hls {
|
||||
enabled on;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
# the config for srs http heartbeat, report its info to api-server
|
||||
# @see full.conf for detail config.
|
||||
|
||||
listen 1935;
|
||||
listen 1935
|
||||
max_connections 1000;
|
||||
heartbeat {
|
||||
enabled on;
|
||||
interval 9.3;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
# @see full.conf for detail config.
|
||||
|
||||
listen 1935;
|
||||
max_connections 1000;
|
||||
http_stream {
|
||||
enabled on;
|
||||
listen 8080;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# @see full.conf for detail config.
|
||||
|
||||
listen 1935;
|
||||
max_connections 1000;
|
||||
srs_log_tank file;
|
||||
srs_log_file ./objs/srs.log;
|
||||
vhost __defaultVhost__ {
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
# @see full.conf for detail config.
|
||||
|
||||
listen 1935;
|
||||
max_connections 1000;
|
||||
vhost __defaultVhost__ {
|
||||
ingest livestream {
|
||||
enabled on;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
# @see full.conf for detail config.
|
||||
|
||||
listen 19350;
|
||||
max_connections 1000;
|
||||
pid objs/origin.pid;
|
||||
srs_log_file ./objs/origin.log;
|
||||
vhost __defaultVhost__ {
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
# @see full.conf for detail config.
|
||||
|
||||
listen 1935;
|
||||
max_connections 1000;
|
||||
vhost __defaultVhost__ {
|
||||
gop_cache off;
|
||||
queue_length 10;
|
||||
|
|
|
@ -3,5 +3,6 @@
|
|||
# @see full.conf for detail config.
|
||||
|
||||
listen 1935;
|
||||
max_connections 1000;
|
||||
vhost __defaultVhost__ {
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# @see full.conf for detail config.
|
||||
|
||||
listen 1935;
|
||||
max_connections 1000;
|
||||
srs_log_tank file;
|
||||
srs_log_file ./objs/srs.log;
|
||||
http_api {
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
# @see full.conf for detail config.
|
||||
|
||||
listen 1935;
|
||||
max_connections 1000;
|
||||
vhost __defaultVhost__ {
|
||||
hls {
|
||||
enabled on;
|
||||
|
|
|
@ -23,6 +23,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
||||
#include <srs_app_config.hpp>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
@ -1405,6 +1406,18 @@ int SrsConfig::check_config()
|
|||
return ret;
|
||||
}
|
||||
|
||||
// check max connections of system limits
|
||||
if (true) {
|
||||
int max_open_files = sysconf(_SC_OPEN_MAX);
|
||||
if (get_max_connections() > max_open_files) {
|
||||
ret = ERROR_SYSTEM_CONFIG_INVALID;
|
||||
srs_error("invalid max_connections=%d, system limit to %d, ret=%d. "
|
||||
"you can login as root and set the limit: ulimit -HSn %d", get_max_connections(), max_open_files,
|
||||
ret, get_max_connections());
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// check heartbeat
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -197,7 +197,9 @@ void SrsFastLog::error(const char* tag, int context_id, const char* fmt, ...)
|
|||
va_end(ap);
|
||||
|
||||
// add strerror() to error msg.
|
||||
if (errno != 0) {
|
||||
size += snprintf(log_data + size, LOG_MAX_SIZE - size, "(%s)", strerror(errno));
|
||||
}
|
||||
|
||||
write_log(fd, log_data, size, SrsLogLevel::Error);
|
||||
}
|
||||
|
|
|
@ -1787,11 +1787,13 @@ VOID TEST(ConfigMainTest, ParseEmpty)
|
|||
VOID TEST(ConfigMainTest, ParseMinConf)
|
||||
{
|
||||
MockSrsConfig conf;
|
||||
EXPECT_TRUE(ERROR_SUCCESS == conf.parse("listen 1935;"));
|
||||
EXPECT_TRUE(ERROR_SUCCESS == conf.parse("listen 1935; max_connections 1000;"));
|
||||
|
||||
vector<string> listens = conf.get_listen();
|
||||
EXPECT_EQ(1, (int)listens.size());
|
||||
EXPECT_STREQ("1935", listens.at(0).c_str());
|
||||
|
||||
EXPECT_EQ(1000, conf.get_max_connections());
|
||||
}
|
||||
|
||||
VOID TEST(ConfigMainTest, ParseInvalidDirective)
|
||||
|
@ -4364,3 +4366,94 @@ VOID TEST(ConfigMainTest, CheckConf_listen)
|
|||
EXPECT_TRUE(ERROR_SUCCESS != conf.parse("listen -1935;"));
|
||||
}
|
||||
}
|
||||
|
||||
VOID TEST(ConfigMainTest, CheckConf_pid)
|
||||
{
|
||||
if (true) {
|
||||
MockSrsConfig conf;
|
||||
EXPECT_TRUE(ERROR_SUCCESS != conf.parse("pids ./objs/srs.pid;"));
|
||||
}
|
||||
}
|
||||
|
||||
VOID TEST(ConfigMainTest, CheckConf_chunk_size)
|
||||
{
|
||||
if (true) {
|
||||
MockSrsConfig conf;
|
||||
EXPECT_TRUE(ERROR_SUCCESS != conf.parse("chunk_sizes 60000;"));
|
||||
}
|
||||
|
||||
if (true) {
|
||||
MockSrsConfig conf;
|
||||
EXPECT_TRUE(ERROR_SUCCESS != conf.parse("chunk_size 0;"));
|
||||
}
|
||||
|
||||
if (true) {
|
||||
MockSrsConfig conf;
|
||||
EXPECT_TRUE(ERROR_SUCCESS != conf.parse("chunk_size 1;"));
|
||||
}
|
||||
|
||||
if (true) {
|
||||
MockSrsConfig conf;
|
||||
EXPECT_TRUE(ERROR_SUCCESS != conf.parse("chunk_size 127;"));
|
||||
}
|
||||
|
||||
if (true) {
|
||||
MockSrsConfig conf;
|
||||
EXPECT_TRUE(ERROR_SUCCESS != conf.parse("chunk_size -1;"));
|
||||
}
|
||||
|
||||
if (true) {
|
||||
MockSrsConfig conf;
|
||||
EXPECT_TRUE(ERROR_SUCCESS != conf.parse("chunk_size -4096;"));
|
||||
}
|
||||
|
||||
if (true) {
|
||||
MockSrsConfig conf;
|
||||
EXPECT_TRUE(ERROR_SUCCESS != conf.parse("chunk_size 65536;"));
|
||||
}
|
||||
}
|
||||
|
||||
VOID TEST(ConfigMainTest, CheckConf_ff_log_dir)
|
||||
{
|
||||
if (true) {
|
||||
MockSrsConfig conf;
|
||||
EXPECT_TRUE(ERROR_SUCCESS != conf.parse("ff_log_dirs ./objs;"));
|
||||
}
|
||||
}
|
||||
|
||||
VOID TEST(ConfigMainTest, CheckConf_srs_log_level)
|
||||
{
|
||||
if (true) {
|
||||
MockSrsConfig conf;
|
||||
EXPECT_TRUE(ERROR_SUCCESS != conf.parse("srs_log_levels trace;"));
|
||||
}
|
||||
}
|
||||
|
||||
VOID TEST(ConfigMainTest, CheckConf_srs_log_file)
|
||||
{
|
||||
if (true) {
|
||||
MockSrsConfig conf;
|
||||
EXPECT_TRUE(ERROR_SUCCESS != conf.parse("srs_log_files ./objs/srs.log;"));
|
||||
}
|
||||
}
|
||||
|
||||
VOID TEST(ConfigMainTest, CheckConf_max_connections)
|
||||
{
|
||||
if (true) {
|
||||
MockSrsConfig conf;
|
||||
EXPECT_TRUE(ERROR_SUCCESS != conf.parse("max_connectionss 1000;"));
|
||||
}
|
||||
|
||||
if (true) {
|
||||
MockSrsConfig conf;
|
||||
EXPECT_TRUE(ERROR_SUCCESS != conf.parse("max_connections 0;"));
|
||||
}
|
||||
}
|
||||
|
||||
VOID TEST(ConfigMainTest, CheckConf_)
|
||||
{
|
||||
if (true) {
|
||||
MockSrsConfig conf;
|
||||
EXPECT_TRUE(ERROR_SUCCESS != conf.parse("listens 1935;"));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue