Re: [uWSGI] php plugin ends with sapi global error, no start (SOLVED)

2019-02-06 Thread Krzysztof Warzecha
Hi,

Glad you got that working.


> However, it is for me still a riddle, why the result of "ldd
> php71_plugin.so" pointed to the wrong library.

I cannot comment on that as I don't know yet where it pointed :).
Could you post output from "ldd php71_plugin.so | grep php"?

Right now I can make few assumptions and hopefully point you in the
right direction.


>> 1 - download php and build it with: ./configure
>> --prefix=/usr/local/php71-emb --enable-mbstring --enable-embed

Which release of php have you downloaded? Current git master produces
libphp8.so. I'm assuming you've downloaded php71 release.


>> make, and make install.

Where did that put libphp7.so? Somewhere near
/usr/local/php71-emb/lib/libphp7.so, right? When starting uwsgi, are
you using --dlopen /usr/lib/libphp7.1.so (Debian's libphp-embed) or
--dlopen /usr/local/php71-emb/lib/libphp7.so (built from source)?

-- 
Krzysztof Warzecha
___
uWSGI mailing list
uWSGI@lists.unbit.it
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi


Re: [uWSGI] php plugin ends with sapi global error, no start

2019-02-03 Thread Krzysztof Warzecha
> Steps to reproduce:
> 1 - download php and build it with: ./configure
> --prefix=/usr/local/php71-emb --enable-mbstring --enable-embed
> make, and make install.

Is there any reason why you are not using libphp7.1-embed from the
repositories? (I'm assuming you are running Debian)

> 2 - build the plugin: UWSGICONFIG_PHPDIR=/usr/local/php71-emb python
> uwsgiconfig.py --plugin plugins/php default php71

FYI I'm using:

- name: "pushd php-plugins; ./configure && make; popd"
  command: >
chdir=/home/uwsgi-build/src/
creates=/home/uwsgi-build/src/{{ item.name }}_plugin.so
env CC=clang
UWSGICONFIG_PHPPATH=/usr/bin/{{ item.config }}
python uwsgiconfig.py --plugin plugins/php core {{ item.name }}
  with_items:
  - { name: php72, config: php-config7.2 }
  - { name: php71, config: php-config7.1 }
  - { name: php70, config: php-config7.0 }
  - { name: php56, config: php-config5.6 }

Looking at plugins/php/uwsgiplugin.py it seems that your version is
doing basically the same thing.


Could you show us the output from "ldd php71_plugin.so"? It should
import sapi_globals from libphp7.so.

Is it possible that you don't have libphp7.so in your system, but
libphp7.1.so? Could you try to execute something like this?

./uwsgi --dlopen /usr/lib/libphp7.1.so --plugin php71 --master
--socket :3030 --processes 4

-- 
Krzysztof Warzecha
___
uWSGI mailing list
uWSGI@lists.unbit.it
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi


Re: [uWSGI] Linux KSM

2019-02-01 Thread Krzysztof Warzecha
Hello,

docs:

https://uwsgi-docs.readthedocs.io/en/latest/KSM.html
https://www.kernel.org/doc/Documentation/vm/ksm.txt
https://www.kernel.org/doc/html/latest/admin-guide/mm/ksm.html

The way I understand it, --ksm=10 tells uwsgi to call
madvise(MADV_MERGABLE) on worker's memory, on every 10th request.
Linux kernel will then consider that memory for same-page
de-duplication. It works nice if you have uwsgi emperor with many
vassals. It should work with many separate uwsgi instances too.


> would you recommend to enable it

In theory you can save a bit of memory, but I'm pretty sure you'll
have to benchmark it. Enable it and use /sys/kernel/mm/ksm/ to trigger
merge and measure how effective it is (with stats from
/sys/kernel/mm/ksm/pages_sharing).

-- 
Krzysztof Warzecha
___
uWSGI mailing list
uWSGI@lists.unbit.it
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi


Re: [uWSGI] why uwsgi invokes /bin/bash

2018-08-09 Thread Krzysztof Warzecha
Hi,

May I suggest attaching strace to your systemd unit?

[Service]
ExecStart=/usr/bin/strace -o /tmp/strace -vvfftt -e trace=%process -s
5000 /usr/sbin/uwsgi --ini /opt/ae-dir/etc/uwsgi/web2ldap.ini

With something similar to this you should be able to see in
/tmp/strace what and how / where is executing bash.


If I had to guess, something probably uses system() and you have
/bin/sh linked to bash.

-- 
Krzysztof Warzecha
___
uWSGI mailing list
uWSGI@lists.unbit.it
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi


Re: [uWSGI] PyPy issue

2018-02-12 Thread Krzysztof Warzecha
)
>
>   File "/home/erob/ncvs/django/django/template/base.py", line 199, in
> _render
>
> return self.nodelist.render(context)
>
>   File "/home/erob/ncvs/django/django/template/base.py", line 990, in
> render
>
> bit = node.render_annotated(context)
>
>   File "/home/erob/ncvs/django/django/template/base.py", line 957, in
> render_annotated
>
> return self.render(context)
>
>   File "/home/erob/ncvs/django/django/template/defaulttags.py", line
> 322, in render
>
> return nodelist.render(context)
>
>   File "/home/erob/ncvs/django/django/template/base.py", line 990, in
> render
>
> bit = node.render_annotated(context)
>
>   File "/home/erob/ncvs/django/django/template/base.py", line 957, in
> render_annotated
>
> return self.render(context)
>
>   File "/home/erob/ncvs/django/django/template/base.py", line 1040, in
> render
>
> output = self.filter_expression.resolve(context)
>
>   File "/home/erob/ncvs/django/django/template/base.py", line 708, in
> resolve
>
> obj = self.var.resolve(context)
>
>   File "/home/erob/ncvs/django/django/template/base.py", line 849, in
> resolve
>
> value = self._resolve_lookup(context)
>
>   File "/home/erob/ncvs/django/django/template/base.py", line 911, in
> _resolve_lookup
>
> current = current()
>
>   File "/home/erob/ncvs/django/django/http/request.py", line 162, in
> get_raw_uri
>
> host=self._get_raw_host(),
>
>   File "/home/erob/ncvs/django/django/http/request.py", line 89, in
> _get_raw_host
>
> host = self.META['SERVER_NAME']
>
> KeyError: u'SERVER_NAME'
>
> From cffi callback :
>
> Traceback (most recent call last):
>
>   File "c callback", line 478, in uwsgi_pypy_wsgi_handler
>
>   File "./benchmark/wsgi.py", line 20, in application
>
> return WSGIHandler()(environ, start_response)
>
>   File "/home/erob/ncvs/django/django/core/handlers/wsgi.py", line 157,
> in __call__
>
> response = self.get_response(request)
>
>   File "/home/erob/ncvs/django/django/core/handlers/base.py", line 124,
> in get_response
>
> response = self._middleware_chain(request)
>
>   File "/home/erob/ncvs/django/django/core/handlers/exception.py", line
> 43, in inner
>
> response = response_for_exception(request, exc)
>
>   File "/home/erob/ncvs/django/django/core/handlers/exception.py", line
> 93, in response_for_exception
>
> response = handle_uncaught_exception(request,
> get_resolver(get_urlconf()), sys.exc_info())
>
>   File "/home/erob/ncvs/django/django/core/handlers/exception.py", line
> 139, in handle_uncaught_exception
>
> return debug.technical_500_response(request, *exc_info)
>
>   File "/home/erob/ncvs/django/django/views/debug.py", line 84, in
> technical_500_response
>
> html = reporter.get_traceback_html()
>
>   File "/home/erob/ncvs/django/django/views/debug.py", line 328, in
> get_traceback_html
>
> return t.render(c)
>
>   File "/home/erob/ncvs/django/django/template/base.py", line 207, in
> render
>
> return self._render(context)
>
>   File "/home/erob/ncvs/django/django/template/base.py", line 199, in
> _render
>
> return self.nodelist.render(context)
>
>   File "/home/erob/ncvs/django/django/template/base.py", line 990, in
> render
>
> bit = node.render_annotated(context)
>
>   File "/home/erob/ncvs/django/django/template/base.py", line 957, in
> render_annotated
>
> return self.render(context)
>
>   File "/home/erob/ncvs/django/django/template/defaulttags.py", line
> 322, in render
>
> return nodelist.render(context)
>
>   File "/home/erob/ncvs/django/django/template/base.py", line 990, in
> render
>
> bit = node.render_annotated(context)
>
>   File "/home/erob/ncvs/django/django/template/base.py", line 957, in
> render_annotated
>
> return self.render(context)
>
>   File "/home/erob/ncvs/django/django/template/base.py", line 1040, in
> render
>
> output = self.filter_expression.resolve(context)
>
>   File "/home/erob/ncvs/django/django/template/base.py", line 708, in
> resolve
>
> obj = self.var.resolve(context)
>
>   File "/home/erob/ncvs/django/django/template/base.py", line 849, in
> resolve
>
> value = self._resolve_lookup(context)
>
>   File "/home/erob/ncvs/django/django/template/base.py", line 911, in
> _resolve_lookup
>
> current = current()
>
>   File "/home/erob/ncvs/django/django/http/request.py", line 162, in
> get_raw_uri
>
> host=self._get_raw_host(),
>
>   File "/home/erob/ncvs/django/django/http/request.py", line 89, in
> _get_raw_host
>
> host = self.META['SERVER_NAME']
>
> KeyError: u'SERVER_NAME'
>
> [pid: 14861|app: -1|req: -1/1] 127.0.0.1 () {36 vars in 444 bytes} [Fri
> Feb  9 11:30:23 2018] GET /benchmark/ => generated 0 bytes in 1729 msecs
> (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)
>
> SIGINT/SIGQUIT received...killing workers...
>
> worker 1 buried after 1 seconds
>
> goodbye to uWSGI.
>
> VACUUM: pidfile removed.
>
>
>
>
> Le 2018-02-09 à 05:54, Krzysztof Warzecha a écrit :
>
> Hello,
>
> On 9 February 2018 at 11:29, Etienne Robillard <tkad...@yandex.com> wrote:
>
> Hi Krzysztof,
>
> I found something highly relevant to my issue:
> http://lists.unbit.it/pipermail/uwsgi/2014-June/007389.html
>
> So I followed Roberto's suggestion and removed my __pycache__ dir but the
> issue is persisting.
>
> What do you think? Should i attempt to patch pypy_setup.py ?
>
> Yes, this looks like sensible next step.
>
> But just to be sure, before you do that, confirm that your nginx is
> correctly sending REQUEST_METHOD header to 127.0.0.1:8000.
>
>
> --
> Etienne Robillard
> tkad...@yandex.com
> https://www.isotopesoftware.ca/
>
>
>
> ___
> uWSGI mailing list
> uWSGI@lists.unbit.it
> http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
>
>
> --
> Etienne Robillard
> tkad...@yandex.com
> https://www.isotopesoftware.ca/



-- 
Krzysztof Warzecha
___
uWSGI mailing list
uWSGI@lists.unbit.it
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi


Re: [uWSGI] PyPy issue

2018-02-09 Thread Krzysztof Warzecha
Hello,

On 9 February 2018 at 11:29, Etienne Robillard <tkad...@yandex.com> wrote:
> Hi Krzysztof,
>
> I found something highly relevant to my issue:
> http://lists.unbit.it/pipermail/uwsgi/2014-June/007389.html
>
> So I followed Roberto's suggestion and removed my __pycache__ dir but the
> issue is persisting.
>
> What do you think? Should i attempt to patch pypy_setup.py ?

Yes, this looks like sensible next step.

But just to be sure, before you do that, confirm that your nginx is
correctly sending REQUEST_METHOD header to 127.0.0.1:8000.

-- 
Krzysztof Warzecha
___
uWSGI mailing list
uWSGI@lists.unbit.it
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi


Re: [uWSGI] PyPy issue

2018-02-08 Thread Krzysztof Warzecha
OK then. I have few more debugging tips, but no solution yet. Let's
see what nginx is sending to uwsgi. Please configure uwsgi with:

[uwsgi]
socket=127.0.0.1:8000

And please use strace (strace -p $PID -p $PID_2 ... -p $PID_N -vvfftt
-o /tmp/strace -s 5000) or tcpdump to confirm if nginx is or is not
sending the REQUEST_METHOD header.

For the record, this is how the code for populating wsgi environ looks like:

https://github.com/unbit/uwsgi/blob/2.0.15/plugins/pypy/pypy_setup.py#L451-L472


Could you confirm that it works if you replace socket=... with
http-socket=... in the uwsgi config and uwsgi_pass with proxy_pass
(with appropriate include ...) in the nginx conf?


If you configure your uwsgi with cpython instead of pypy, does it work
with similar configuration?

-- 
Krzysztof Warzecha
___
uWSGI mailing list
uWSGI@lists.unbit.it
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi


Re: [uWSGI] PyPy issue

2018-02-08 Thread Krzysztof Warzecha
Hello,

> [uwsgi]
> ...
> socket=127.0.0.1:8000

Is there any web server in the front of the uwsgi? If this is nginx,
are you sure you are using "uwsgi_pass" instead of, for example,
"proxy_pass"?


Could you replace socket= with http-socket= and query it with curl, like that?

curl -v http://127.0.0.1:8000/benchmark

-- 
Krzysztof Warzecha
___
uWSGI mailing list
uWSGI@lists.unbit.it
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi