Unit does not work correctly

Алексей Бердников a.berdnikow at yandex.ru
Tue Oct 2 10:41:43 UTC 2018


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)







More information about the unit mailing list