<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">пт, 6 июл. 2018 г. в 6:32, Maxim Dounin <<a href="mailto:mdounin@mdounin.ru">mdounin@mdounin.ru</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello!<br>
<br>
On Thu, Jul 05, 2018 at 07:29:37PM +0500, Илья Шипицин wrote:<br>
<br>
[...]<br>
<br>
> # cat /var/log/nginx/error.log | tail -2<br>
> 2018/07/05 14:27:53 [alert] 1546#1546: 512 worker_connections are not enough<br>
> 2018/07/05 14:27:53 [alert] 1545#1545: worker process 1546 exited with<br>
> fatal code 2 and cannot be respawned<br>
> #<br>
> <br>
> <br>
> кажется, что было бы логично отсекать такие ошибки во время "nginx -t"<br>
> что думаете ?<br>
<br>
Кажется, ситуация не отличается принципиально от любой другой, <br>
когда nginx'у не хватает соединений для нормальной работы. Но <br>
можно попробовать какой-то такой патч, сколько-то ног он наверное <br>
сохранит:<br></blockquote><div><br></div><div><br></div><div><br></div><div>попробовал, все получается так, как задумано</div><div><br></div><div>[root@xxx nginx-1.15.1]# objs/nginx -t<br>nginx: the configuration file /etc/nginx/nginx.conf syntax is ok<br>nginx: [emerg] 512 worker_connections are not enough for nginx with 701 listening sockets<br>nginx: configuration file /etc/nginx/nginx.conf test failed</div><div><br></div><div><br></div><div>[root@xxx nginx-1.15.1]# nginx -t<br>nginx: the configuration file /etc/nginx/nginx.conf syntax is ok<br>nginx: configuration file /etc/nginx/nginx.conf test is successful<br>[root@xxx nginx-1.15.1]# <br><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
# HG changeset patch<br>
# User Maxim Dounin <<a href="mailto:mdounin@mdounin.ru" target="_blank">mdounin@mdounin.ru</a>><br>
# Date 1530840179 -10800<br>
# Fri Jul 06 04:22:59 2018 +0300<br>
# Node ID 7f4aa03a8a21164881429568bd2f70a311c5c599<br>
# Parent 54683f650cbdcd73f7f8d845c843295978da5a85<br>
Events: added configuration check on the number of connections.<br>
<br>
There should be at least one worker connection for each listening socket,<br>
plus an additional connection for channel between worker and master,<br>
or starting worker process will fail.<br>
<br>
diff --git a/src/event/ngx_event.c b/src/event/ngx_event.c<br>
--- a/src/event/ngx_event.c<br>
+++ b/src/event/ngx_event.c<br>
@@ -416,6 +416,21 @@ ngx_event_init_conf(ngx_cycle_t *cycle, <br>
return NGX_CONF_ERROR;<br>
}<br>
<br>
+ if (cycle->connection_n < cycle->listening.nelts + 1) {<br>
+<br>
+ /*<br>
+ * there should be at least one connection for each listening<br>
+ * socket, plus one connection for channel<br>
+ */<br>
+<br>
+ ngx_log_error(NGX_LOG_EMERG, cycle->log, 0,<br>
+ "%ui worker_connections are not enough "<br>
+ "for nginx with %ui listening sockets",<br>
+ cycle->connection_n, cycle->listening.nelts);<br>
+<br>
+ return NGX_CONF_ERROR;<br>
+ }<br>
+<br>
return NGX_CONF_OK;<br>
}<br>
<br>
<br>
<br>
-- <br>
Maxim Dounin<br>
<a href="http://mdounin.ru/" rel="noreferrer" target="_blank">http://mdounin.ru/</a><br>
_______________________________________________<br>
nginx-ru mailing list<br>
<a href="mailto:nginx-ru@nginx.org" target="_blank">nginx-ru@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx-ru" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx-ru</a></blockquote></div></div>