From a.berdnikow at yandex.ru Tue Oct 2 10:41:43 2018 From: a.berdnikow at yandex.ru (=?utf-8?B?0JDQu9C10LrRgdC10Lkg0JHQtdGA0LTQvdC40LrQvtCy?=) Date: Tue, 02 Oct 2018 15:41:43 +0500 Subject: Unit does not work correctly Message-ID: <1955971538476903@iva7-7c2970ec7645.qloud-c.yandex.net> Hello. I have a problem with Unit on Ubuntu 18.04.1. After running Unit and Creating Configuration Objects, one Unit "test_app" application process will be started. I'm sending a request with curl http://localhost:8400/ command. Only one request will be processed correctly. There will be no response to the second and next requests. After completion of the process with the command kill -9 UnitPID, the newly launched process will work also. unit.conf { "listeners": { "*:8400": { "application": "test_app" } }, "applications": { "test_app": { "type": "python 3.6", "module": "wsgi", "path": "/usr/share/doc/unit-python3.6/examples/python-app" } } } wsgi.py import os import datetime import sys def application(environ, start_response): output = datetime.datetime.now().strftime("%Y-%m-%d %I:%M:%S %p") output += "\n\nPython: " output += sys.version output += "\n\nENV Variables:\n\n" for param in os.environ.keys(): output += param output += "\t" output += os.environ[param] output += "\n" start_response('200 OK', [('Content-type', 'text/plain')]) return [s.encode('utf8') for s in output] $ ps -efH | grep unit root 3283 1823 0 11:28 pts/0 00:00:00 grep --color=auto unit root 3090 1 0 10:33 ? 00:00:00 unit: main v1.4 [/usr/sbin/unitd --log /var/log/unit.log --pid /run/unit.pid] nobody 3093 3090 0 10:33 ? 00:00:00 unit: controller nobody 3094 3090 0 10:33 ? 00:00:00 unit: router nobody 3242 3090 0 11:24 ? 00:00:00 unit: "test_app" application /var/log/unit.log with bash commands. $ apt-get install unit $ apt-get install unit-python3.6 2018/10/02 10:14:36 [info] 2787#2787 discovery started 2018/10/02 10:14:36 [notice] 2787#2787 no modules matching: "/usr/lib/unit/modules/*.unit.so" found 2018/10/02 10:14:36 [notice] 2786#2786 process 2787 exited with code 0 2018/10/02 10:14:36 [info] 2789#2789 router started 2018/10/02 10:14:36 [info] 2788#2788 controller started 2018/10/02 10:14:36 [info] 2789#2789 OpenSSL 1.1.0g 2 Nov 2017, 1010007f $ service unit restart 2018/10/02 10:24:58 [notice] 2786#2786 process 2788 exited with code 0 2018/10/02 10:24:58 [info] 2970#2970 discovery started 2018/10/02 10:24:58 [notice] 2970#2970 module: python 3.6.5 "/usr/lib/unit/modules/python3.6.unit.so" 2018/10/02 10:24:58 [notice] 2968#2968 process 2970 exited with code 0 2018/10/02 10:24:58 [info] 2974#2974 router started 2018/10/02 10:24:58 [info] 2972#2972 controller started 2018/10/02 10:24:58 [info] 2974#2974 OpenSSL 1.1.0g 2 Nov 2017, 1010007f $ service unit restart (again) 2018/10/02 10:33:47 [notice] 2968#2968 process 2972 exited with code 0 2018/10/02 10:33:47 [info] 3091#3091 discovery started 2018/10/02 10:33:47 [notice] 3091#3091 module: python 3.6.5 "/usr/lib/unit/modules/python3.6.unit.so" 2018/10/02 10:33:47 [notice] 3090#3090 process 3091 exited with code 0 2018/10/02 10:33:47 [info] 3094#3094 router started 2018/10/02 10:33:47 [info] 3093#3093 controller started 2018/10/02 10:33:47 [info] 3094#3094 OpenSSL 1.1.0g 2 Nov 2017, 1010007f $ curl -X PUT -d @unit.conf --unix-socket /run/control.unit.sock http://localhost/config/ 2018/10/02 11:24:54 [info] 3242#3242 "test_app" application started $ curl http://localhost:8400/ 2018/10/02 11:32:55.871 [warn] 3242#3242 [unit] port_send(8, 28) failed: Resource temporarily unavailable (11) 2018/10/02 11:32:55.871 [warn] 3242#3242 [unit] port_send(8, 16) failed: Resource temporarily unavailable (11) 2018/10/02 11:32:55.871 [alert] 3242#3242 [unit] #4: last message send failed: Resource temporarily unavailable (11) $ curl http://localhost:8400/ 2018/10/02 11:33:22.478 [warn] 3242#3242 [unit] port_send(8, 28) failed: Resource temporarily unavailable (11) 2018/10/02 11:33:22.479 [warn] 3242#3242 [unit] port_send(8, 16) failed: Resource temporarily unavailable (11) 2018/10/02 11:33:22.479 [alert] 3242#3242 [unit] #5: last message send failed: Resource temporarily unavailable (11) From vbart at nginx.com Tue Oct 2 15:46:57 2018 From: vbart at nginx.com (Valentin V. Bartenev) Date: Tue, 02 Oct 2018 18:46:57 +0300 Subject: Unit does not work correctly In-Reply-To: <1955971538476903@iva7-7c2970ec7645.qloud-c.yandex.net> References: <1955971538476903@iva7-7c2970ec7645.qloud-c.yandex.net> Message-ID: <1928938.AnokqTzfmy@vbart-workstation> On Tuesday 02 October 2018 15:41:43 ??????? ????????? wrote: > Hello. > > I have a problem with Unit on Ubuntu 18.04.1. After running > Unit and Creating Configuration Objects, one Unit "test_app" > application process will be started. I'm sending a request > with curl http://localhost:8400/ command. Only one request > will be processed correctly. There will be no response to > the second and next requests. After completion of the > process with the command kill -9 UnitPID, the newly > launched process will work also. > [..] Thank you for the report, please try the following patch. wbr, Valentin V. Bartenev diff --git a/src/nxt_port.c b/src/nxt_port.c --- a/src/nxt_port.c +++ b/src/nxt_port.c @@ -276,6 +276,8 @@ nxt_port_new_port_handler(nxt_task_t *ta nxt_process_use(task, process, -1); + nxt_fd_nonblocking(task, msg->fd); + port->pair[0] = -1; port->pair[1] = msg->fd; port->max_size = new_port_msg->max_size; diff --git a/src/nxt_unit.c b/src/nxt_unit.c --- a/src/nxt_unit.c +++ b/src/nxt_unit.c @@ -510,7 +510,7 @@ int nxt_unit_process_msg(nxt_unit_ctx_t *ctx, nxt_unit_port_id_t *port_id, void *buf, size_t buf_size, void *oob, size_t oob_size) { - int fd, rc; + int fd, rc, nb; pid_t pid; nxt_queue_t incoming_buf; struct cmsghdr *cm; @@ -611,6 +611,15 @@ nxt_unit_process_msg(nxt_unit_ctx_t *ctx port_msg->stream, (int) new_port_msg->pid, (int) new_port_msg->id, fd); + nb = 0; + + if (nxt_slow_path(ioctl(fd, FIONBIO, &nb) == -1)) { + nxt_unit_alert(ctx, "#%"PRIu32": new_port: ioctl(%d, FIONBIO, 0) " + "failed: %s (%d)", fd, strerror(errno), errno); + + goto fail; + } + nxt_unit_port_id_init(&new_port.id, new_port_msg->pid, new_port_msg->id); From vbart at nginx.com Thu Oct 25 17:26:56 2018 From: vbart at nginx.com (Valentin V. Bartenev) Date: Thu, 25 Oct 2018 20:26:56 +0300 Subject: Unit 1.5 release Message-ID: <5070793.DMeoWI2HCB@vbart-workstation> Hello, I'm glad to announce a new release of NGINX Unit. This release introduces preliminary Node.js support. Currently it lacks WebSockets, and there's a known problem with "promises". However, our admirable users have already started testing it even before the release: - https://medium.com/house-organ/what-an-absolute-unit-a36851e72554 Now it even easier, since Node.js package is published in npm: - https://www.npmjs.com/package/unit-http So feel free to try it and give us feedback on: - Github: https://github.com/nginx/unit/issues - Mailing list: https://mailman.nginx.org/mailman/listinfo/unit We will continue improving Node.js support in future releases. Among other features we are working on right now: WebSockets, Java module, flexible request routing, and serving of static media assets. Changes with Unit 1.5 25 Oct 2018 *) Change: the "type" of application object for Go was changed to "external". *) Feature: initial version of Node.js package with basic HTTP request-response support. *) Feature: compatibility with LibreSSL. *) Feature: --libdir and --incdir ./configure options to install libunit headers and static library. *) Bugfix: connection might be closed prematurely while sending response; the bug had appeared in 1.3. *) Bugfix: application processes might have stopped handling requests, producing "last message send failed: Resource temporarily unavailable" alerts in log; the bug had appeared in 1.4. *) Bugfix: Go applications didn't work when Unit was built with musl C library. wbr, Valentin V. Bartenev