unbit / uwsgi

uWSGI application server container
http://projects.unbit.it/uwsgi
Other
3.47k stars 692 forks source link

monolith build #1449

Closed ghost closed 7 years ago

ghost commented 7 years ago

Hi,

Whether and how I can build a monolith uwsgi. I mean one binary without any additional shared libraries, etc. I would like to copy the uwsgi binary to the container and get rid of the operating system.

Eg. currently I'm doing this:

# git clone ...uwsgi...
# python uwsgiconfig.py --plugin plugins/php default php
# python uwsgiconfig.py -b php

After that I get a binary ./uwsgi, but it requires additional file ./php_plugin.so When I delete ./php_plugin.so - ./uwsgi print an error message. How can I embed this plugin in uwsgi?

I would also like to embed my configuration INI, during the building. For this I found "embed_config="

xrmx commented 7 years ago

There's some hints here: http://uwsgi-docs.readthedocs.io/en/latest/BuildSystem.html#plugins-and-uwsgiplugin-py and a git grep of embedded_plugins may gives you some more hints. Of course documentation may be improved and in fact PR are very welcome!

ghost commented 7 years ago

I read earlier this documentation, but either something is not working, or I do not understand something.

After you download the repo from github. I do only: python uwsgiconfig.py -b php According to the documentation, this should use the profile buildconf/php.ini

[uwsgi] main_plugin = php inherit = base

buildconf/base.ini contains

embedded_plugins = %(main_plugin)s, ping, cache, nagios, rrdtool, carbon, rpc, corerouter, fastrouter, http, ugreen, signal, syslog, rsyslog, logsocket, router_uwsgi, router_redirect, router_basicauth, zergpool, redislog, mongodblog, router_rewrite, router_http, logfile, router_cache, rawrouter, router_static, sslrouter, spooler, cheaper_busyness, symcall, transformation_tofile, transformation_gzip, transformation_chunked, transformation_offload, router_memcached, router_redis, router_hash, router_expires, router_metrics, transformation_template, stats_pusher_socket, router_fcgi as_shared_library = false

This suggest that main_plugin (php) will be embedded in the uwsgi. The process of building reports:

"-DUWSGI_DECLARE_EMBEDDED_PLUGINS="UDEP(php);UDEP(ping);" " -DUWSGI_LOAD_EMBEDDED_PLUGINS="ULEP(php);" uWSGI linking "... plugins/php/php_plugin.o ..."

Looking at this I am thinking, that the php_plugin is embedded in uwsgi. But it turns out that there is still need a file with symbols?

./uwsgi --ini uwsgi-php.ini

[uWSGI] getting INI configuration from uwsgi-php.ini open("./php_plugin.so"): No such file or directory [core/utils.c line 3710] !!! UNABLE to load uWSGI plugin: Error loading shared library ./php_plugin.so: No such file or directory !!!

I know where the problem is ;)

Missing one sentence in the documentation. By its absence it is not (at least for me) obvious. That when the plug is embedded you do not need to use "plugins = php" in runtime configuration. Above sentence IMHO would be very helpful at the end of http://uwsgi-docs.readthedocs.io/en/latest/BuildSystem.html#plugins-and-uwsgiplugin-py

The second issue is the fact that uwsgi prints a message "!!! UNABLE to load uWSGI plugin: Error loading shared library". Which is already embedded, loaded. The message should look like this "!!! uWSGI plugin: php_plugin is already embedded. Don't use plugins = php" or something like that.

@xrmx Thank you for your help.

ghost commented 7 years ago

I have one more question. How do I embed the following libraries to uwsgi being built?

ldd ./uwsgi /lib/ld-musl-x86_64.so.1 (0x55b8de151000) libz.so.1 => /lib/libz.so.1 (0x7febd2676000) libpcre.so.1 => /usr/lib/libpcre.so.1 (0x7febd241a000) libxml2.so.2 => /usr/lib/libxml2.so.2 (0x7febd20ef000) libphp7.so => /usr/local/lib/libphp7.so (0x7febd1324000) libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x55b8de151000) libpng16.so.16 => /usr/lib/libpng16.so.16 (0x7febd10f7000)

xrmx commented 7 years ago

I don't think out build system (uwsgiconfig.py) permits to build stuff statically. Feel free to open a PR if you manage to sort it out.

Again feel free to open any update to uwsgi-docs to make documentation clear.