diff --git a/core/utils.c b/core/utils.c index 18234e57..09d79df8 100644 --- a/core/utils.c +++ b/core/utils.c @@ -1112,6 +1112,7 @@ void sanitize_args() { uwsgi.ignore_write_errors = 1; } + if (uwsgi.cheaper_count > 0 && uwsgi.cheaper_count >= uwsgi.numproc) { uwsgi_log("invalid cheaper value: must be lower than processes\n"); exit(1); diff --git a/core/uwsgi.c b/core/uwsgi.c index 0b43b15a..fdb037b7 100644 --- a/core/uwsgi.c +++ b/core/uwsgi.c @@ -1938,6 +1938,16 @@ int uwsgi_start(void *v_argv) { uwsgi_error("setrlimit()"); } } + + if (!getrlimit(RLIMIT_NPROC, &uwsgi.rl_nproc)) { + if (uwsgi.rl_nproc.rlim_cur != RLIM_INFINITY) { + uwsgi_log("your processes number limit is %d\n", (int) uwsgi.rl_nproc.rlim_cur); + if ((int)uwsgi.rl_nproc.rlim_cur < uwsgi.numproc+uwsgi.master_process) { + uwsgi.numproc = uwsgi.rl_nproc.rlim_cur - 1; + uwsgi_log("!!! number of workers adjusted to %d due to system limits !!!\n", uwsgi.numproc); + } + } + } #endif #ifndef __OpenBSD__ @@ -1970,7 +1980,6 @@ int uwsgi_start(void *v_argv) { } #endif - uwsgi_log_initial("your memory page size is %d bytes\n", uwsgi.page_size); if (uwsgi.buffer_size > 65536) {