@@ -1492,41 +1492,13 @@ srs_error_t SrsConfig::reload_conf(SrsConfig* conf)
1492
1492
}
1493
1493
}
1494
1494
1495
- // merge config: srs_log_tank
1496
- if (!srs_directive_equals (root->get (" srs_log_tank" ), old_root->get (" srs_log_tank" ))) {
1497
- if ((err = do_reload_srs_log_tank ()) != srs_success) {
1498
- return srs_error_wrap (err, " log tank" );;
1499
- }
1500
- }
1501
-
1502
- // merge config: srs_log_level
1503
- if (!srs_directive_equals (root->get (" srs_log_level" ), old_root->get (" srs_log_level" ))) {
1504
- if ((err = do_reload_srs_log_level ()) != srs_success) {
1505
- return srs_error_wrap (err, " log level" );;
1506
- }
1507
- }
1508
-
1509
- // merge config: srs_log_file
1510
- if (!srs_directive_equals (root->get (" srs_log_file" ), old_root->get (" srs_log_file" ))) {
1511
- if ((err = do_reload_srs_log_file ()) != srs_success) {
1512
- return srs_error_wrap (err, " log file" );;
1513
- }
1514
- }
1515
-
1516
1495
// merge config: max_connections
1517
1496
if (!srs_directive_equals (root->get (" max_connections" ), old_root->get (" max_connections" ))) {
1518
1497
if ((err = do_reload_max_connections ()) != srs_success) {
1519
1498
return srs_error_wrap (err, " max connections" );;
1520
1499
}
1521
1500
}
1522
1501
1523
- // merge config: utc_time
1524
- if (!srs_directive_equals (root->get (" utc_time" ), old_root->get (" utc_time" ))) {
1525
- if ((err = do_reload_utc_time ()) != srs_success) {
1526
- return srs_error_wrap (err, " utc time" );;
1527
- }
1528
- }
1529
-
1530
1502
// merge config: pithy_print_ms
1531
1503
if (!srs_directive_equals (root->get (" pithy_print_ms" ), old_root->get (" pithy_print_ms" ))) {
1532
1504
if ((err = do_reload_pithy_print_ms ()) != srs_success) {
@@ -2946,78 +2918,6 @@ srs_error_t SrsConfig::raw_set_ff_log_dir(string ff_log_dir, bool& applied)
2946
2918
return err;
2947
2919
}
2948
2920
2949
- srs_error_t SrsConfig::raw_set_srs_log_tank (string srs_log_tank, bool & applied)
2950
- {
2951
- srs_error_t err = srs_success;
2952
-
2953
- applied = false ;
2954
-
2955
- SrsConfDirective* conf = root->get_or_create (" srs_log_tank" );
2956
-
2957
- if (conf->arg0 () == srs_log_tank) {
2958
- return err;
2959
- }
2960
-
2961
- conf->args .clear ();
2962
- conf->args .push_back (srs_log_tank);
2963
-
2964
- if ((err = do_reload_srs_log_tank ()) != srs_success) {
2965
- return srs_error_wrap (err, " reload log tank" );
2966
- }
2967
-
2968
- applied = true ;
2969
-
2970
- return err;
2971
- }
2972
-
2973
- srs_error_t SrsConfig::raw_set_srs_log_level (string srs_log_level, bool & applied)
2974
- {
2975
- srs_error_t err = srs_success;
2976
-
2977
- applied = false ;
2978
-
2979
- SrsConfDirective* conf = root->get_or_create (" srs_log_level" );
2980
-
2981
- if (conf->arg0 () == srs_log_level) {
2982
- return err;
2983
- }
2984
-
2985
- conf->args .clear ();
2986
- conf->args .push_back (srs_log_level);
2987
-
2988
- if ((err = do_reload_srs_log_level ()) != srs_success) {
2989
- return srs_error_wrap (err, " reload log level" );
2990
- }
2991
-
2992
- applied = true ;
2993
-
2994
- return err;
2995
- }
2996
-
2997
- srs_error_t SrsConfig::raw_set_srs_log_file (string srs_log_file, bool & applied)
2998
- {
2999
- srs_error_t err = srs_success;
3000
-
3001
- applied = false ;
3002
-
3003
- SrsConfDirective* conf = root->get_or_create (" srs_log_file" );
3004
-
3005
- if (conf->arg0 () == srs_log_file) {
3006
- return err;
3007
- }
3008
-
3009
- conf->args .clear ();
3010
- conf->args .push_back (srs_log_file);
3011
-
3012
- if ((err = do_reload_srs_log_file ()) != srs_success) {
3013
- return srs_error_wrap (err, " reload log file" );
3014
- }
3015
-
3016
- applied = true ;
3017
-
3018
- return err;
3019
- }
3020
-
3021
2921
srs_error_t SrsConfig::raw_set_max_connections (string max_connections, bool & applied)
3022
2922
{
3023
2923
srs_error_t err = srs_success;
@@ -3042,30 +2942,6 @@ srs_error_t SrsConfig::raw_set_max_connections(string max_connections, bool& app
3042
2942
return err;
3043
2943
}
3044
2944
3045
- srs_error_t SrsConfig::raw_set_utc_time (string utc_time, bool & applied)
3046
- {
3047
- srs_error_t err = srs_success;
3048
-
3049
- applied = false ;
3050
-
3051
- SrsConfDirective* conf = root->get_or_create (" utc_time" );
3052
-
3053
- if (conf->arg0 () == utc_time) {
3054
- return err;
3055
- }
3056
-
3057
- conf->args .clear ();
3058
- conf->args .push_back (utc_time);
3059
-
3060
- if ((err = do_reload_utc_time ()) != srs_success) {
3061
- return srs_error_wrap (err, " reload" );
3062
- }
3063
-
3064
- applied = true ;
3065
-
3066
- return err;
3067
- }
3068
-
3069
2945
srs_error_t SrsConfig::raw_set_pithy_print_ms (string pithy_print_ms, bool & applied)
3070
2946
{
3071
2947
srs_error_t err = srs_success;
@@ -3265,54 +3141,6 @@ srs_error_t SrsConfig::do_reload_pid()
3265
3141
return err;
3266
3142
}
3267
3143
3268
- srs_error_t SrsConfig::do_reload_srs_log_tank ()
3269
- {
3270
- srs_error_t err = srs_success;
3271
-
3272
- vector<ISrsReloadHandler*>::iterator it;
3273
- for (it = subscribes.begin (); it != subscribes.end (); ++it) {
3274
- ISrsReloadHandler* subscribe = *it;
3275
- if ((err = subscribe->on_reload_log_tank ()) != srs_success) {
3276
- return srs_error_wrap (err, " notify subscribes reload srs_log_tank failed" );
3277
- }
3278
- }
3279
- srs_trace (" reload srs_log_tank success." );
3280
-
3281
- return err;
3282
- }
3283
-
3284
- srs_error_t SrsConfig::do_reload_srs_log_level ()
3285
- {
3286
- srs_error_t err = srs_success;
3287
-
3288
- vector<ISrsReloadHandler*>::iterator it;
3289
- for (it = subscribes.begin (); it != subscribes.end (); ++it) {
3290
- ISrsReloadHandler* subscribe = *it;
3291
- if ((err = subscribe->on_reload_log_level ()) != srs_success) {
3292
- return srs_error_wrap (err, " notify subscribes reload srs_log_level failed" );
3293
- }
3294
- }
3295
- srs_trace (" reload srs_log_level success." );
3296
-
3297
- return err;
3298
- }
3299
-
3300
- srs_error_t SrsConfig::do_reload_srs_log_file ()
3301
- {
3302
- srs_error_t err = srs_success;
3303
-
3304
- vector<ISrsReloadHandler*>::iterator it;
3305
- for (it = subscribes.begin (); it != subscribes.end (); ++it) {
3306
- ISrsReloadHandler* subscribe = *it;
3307
- if ((err = subscribe->on_reload_log_file ()) != srs_success) {
3308
- return srs_error_wrap (err, " notify subscribes reload srs_log_file failed" );
3309
- }
3310
- }
3311
- srs_trace (" reload srs_log_file success." );
3312
-
3313
- return err;
3314
- }
3315
-
3316
3144
srs_error_t SrsConfig::do_reload_max_connections ()
3317
3145
{
3318
3146
srs_error_t err = srs_success;
@@ -3329,22 +3157,6 @@ srs_error_t SrsConfig::do_reload_max_connections()
3329
3157
return err;
3330
3158
}
3331
3159
3332
- srs_error_t SrsConfig::do_reload_utc_time ()
3333
- {
3334
- srs_error_t err = srs_success;
3335
-
3336
- vector<ISrsReloadHandler*>::iterator it;
3337
- for (it = subscribes.begin (); it != subscribes.end (); ++it) {
3338
- ISrsReloadHandler* subscribe = *it;
3339
- if ((err = subscribe->on_reload_utc_time ()) != srs_success) {
3340
- return srs_error_wrap (err, " utc_time" );
3341
- }
3342
- }
3343
- srs_trace (" reload utc_time success." );
3344
-
3345
- return err;
3346
- }
3347
-
3348
3160
srs_error_t SrsConfig::do_reload_pithy_print_ms ()
3349
3161
{
3350
3162
srs_error_t err = srs_success;
@@ -3581,7 +3393,7 @@ srs_error_t SrsConfig::check_normal_config()
3581
3393
&& n != " ff_log_level" && n != " grace_final_wait" && n != " force_grace_quit"
3582
3394
&& n != " grace_start_wait" && n != " empty_ip_ok" && n != " disable_daemon_for_docker"
3583
3395
&& n != " inotify_auto_reload" && n != " auto_reload_for_docker" && n != " tcmalloc_release_rate"
3584
- ) {
3396
+ && n != " srs_log_flush_interval " && n != " threads " ) {
3585
3397
return srs_error_new (ERROR_SYSTEM_CONFIG_INVALID, " illegal directive %s" , n.c_str ());
3586
3398
}
3587
3399
}
@@ -4293,6 +4105,28 @@ double SrsConfig::tcmalloc_release_rate()
4293
4105
return trr;
4294
4106
}
4295
4107
4108
+ srs_utime_t SrsConfig::get_threads_interval ()
4109
+ {
4110
+ static srs_utime_t DEFAULT = 60 * SRS_UTIME_SECONDS;
4111
+
4112
+ SrsConfDirective* conf = root->get (" threads" );
4113
+ if (!conf) {
4114
+ return DEFAULT;
4115
+ }
4116
+
4117
+ conf = conf->get (" interval" );
4118
+ if (!conf || conf->arg0 ().empty ()) {
4119
+ return DEFAULT;
4120
+ }
4121
+
4122
+ int v = ::atoi (conf->arg0 ().c_str ());
4123
+ if (v <= 0 ) {
4124
+ return DEFAULT;
4125
+ }
4126
+
4127
+ return v * SRS_UTIME_SECONDS;
4128
+ }
4129
+
4296
4130
vector<SrsConfDirective*> SrsConfig::get_stream_casters ()
4297
4131
{
4298
4132
srs_assert (root);
@@ -6989,6 +6823,23 @@ string SrsConfig::get_log_file()
6989
6823
return conf->arg0 ();
6990
6824
}
6991
6825
6826
+ srs_utime_t SrsConfig::srs_log_flush_interval ()
6827
+ {
6828
+ srs_utime_t DEFAULT = 1300 * SRS_UTIME_MILLISECONDS;
6829
+
6830
+ SrsConfDirective* conf = root->get (" srs_log_flush_interval" );
6831
+ if (!conf || conf->arg0 ().empty ()) {
6832
+ return DEFAULT;
6833
+ }
6834
+
6835
+ srs_utime_t v = ::atoi (conf->arg0 ().c_str ()) * SRS_UTIME_MILLISECONDS;
6836
+ if (v <= 0 ) {
6837
+ return DEFAULT;
6838
+ }
6839
+
6840
+ return v;
6841
+ }
6842
+
6992
6843
bool SrsConfig::get_ff_log_enabled ()
6993
6844
{
6994
6845
string log = get_ff_log_dir ();
0 commit comments