uwsgi options --wsgi-file and --module not recognized - wsgi

I am trying to run a Django app using uwsgi. Most instructions I have found refer to a "--wsgi-file" and "--module" to specify the application, but "uwsgi" makes no mention of these options, and when I try and use them:
uwsgi -s /tmp/uwsgi.sock --master --module myapp.wsgi
uwsgi: unrecognized option '--module'
getopt_long() error
And
uwsgi -s /tmp/uwsgi.sock --master --wsgi-file myapp/wsgi.py
uwsgi: unrecognized option '--wsgi-file'
getopt_long() error
When I run it without either, I get:
uwsgi -s /tmp/uwsgi.sock --master
*** Starting uWSGI 2.0.9 (64bit) on [Fri Jul 10 11:12:04 2015] ***
compiled with version: 4.4.7 20120313 (Red Hat 4.4.7-11) on 23 April 2015 19:31:15
os: Linux-2.6.32-504.16.2.el6.x86_64 #1 SMP Tue Mar 10 17:01:00 EDT 2015
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 2
detected binary path: /usr/sbin/uwsgi
your processes number limit is 1024
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /tmp/uwsgi.sock fd 5
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 145536 bytes (142 KB) for 1 cores
*** Operational MODE: single process ***
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 26597)
spawned uWSGI worker 1 (pid: 26598, cores: 1)
Why aren't these options recognized? How am I supposed to specify the app to load? What kind of garbage software is this? Should I go back to using Gunicorn?

This means that the python plugin for uWSGI isn't installed or loaded. To verify run:
$ uwsgi --plugins-list
In general if you have build-essential python-dev etc., you can install via:
$ pip install uwsgi
On Debian or Ubuntu you can also install it via:
$ apt-get install uwsgi-plugin-python
On Linux Alpine you currently have to specify where it is:
$ apk add --update uwsgi-python
$ uwsgi --plugins-dir /usr/lib/uwsgi/ --need-plugin python --plugins-list
*** uWSGI loaded generic plugins ***
*** uWSGI loaded request plugins ***
0: python
...
Alternatively you can specify its full path via:
$ uwsgi --plugin /usr/lib/uwsgi/python_plugin.so --plugins-list

Depending how you installed uwsgi also might also need to install the python plugin. e.g.
apt-get install uwsgi-plugin-python

Related

How to fix "No module named 'encodings'" in Python3.7.1?

I tried to start uwsgi for myproject(mywords_dict):
uwsgi --http :8000 -H /root/mywords_dict/env --chdir mywords_dict -w mywords_dict.wsgi
But received the following error:
Fatal Python error: initfsencoding: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'
I am so confused that uwsgi can work well if I run it after entering virtual env .Python version of 'mywords_dict' is 3.7.1. I have checked that the there is encoding package in mywords_dic/env. And I can run python successfully from there. Does anyone can help?
*** Starting uWSGI 2.0.18 (64bit) on [Fri Aug 30 00:15:16 2019] ***
compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-36) on 29 August
2019 13:49:55
os: Linux-3.10.0-862.14.4.el7.x86_64 #1 SMP Wed Sep 26 15:12:11 UTC 2018
nodename: VM_0_17_centos
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /root
detected binary path: /root/.pyenv/versions/3.7.1/bin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
chdir() to mywords_dict
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 3882
your memory page size is 4096 bytes
detected max file descriptor number: 100001
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uWSGI http bound on :8000 fd 4
spawned uWSGI http 1 (pid: 22645)
uwsgi socket 0 bound to TCP address 127.0.0.1:42301 (port auto-assigned) fd 3
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
Python version: 3.7.1 (default, Nov 11 2018, 01:35:46) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
Set PythonHome to /root/mywords_dict/env
**Fatal Python error: initfsencoding: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'**
This is due to wrong python virtual environment path. It is defined in you .ini file under home variable.
What you need to do is assign to this variable path pointing to the root of your venv. So if your venv path is /home/user/project/venv, just assign this path to the home variable. Be sure not to include the trailing / (slash) in the venv path (since it is later concatenated to /bin/python and you'll end up with double slash.
Then save your .ini file and try starting uWSGI again.
I got the same error.
Fixed after trying these steps :
Uninstall python(38) as administrator. Checking all the boxes during custom installation, including install for all user and precompiling standard library.
Downgrading python38 to 37
I still dont know what & where the error came from though haha.

"undefined symbol: mg_free_type" when installing mod_perl 2.0.10 with Apache 2.4.26 and Perl 5.10.1

I'm trying to install mod_perl 2.0.10 for use with a new Apache 2.4 instance. I've got Apache 2.4.26 up and running by itself, but I also need mod_perl installed for a couple of modules to work.
Here's the problem: mod_perl always fails its tests claiming:
Syntax error on line 82 of .../t/conf/httpd.conf: Cannot load .../src/modules/perl/mod_perl.so into server: .../src/modules/perl/mod_perl.so: undefined symbol: mg_free_type
The only information I could find on this is here: Error when installing mod_perl2. Unfortunately, it didn't solve the problem.
Using CentOS release 6.8 (Final)
x86_64 x86_64 x86_64 GNU/Linux
More from the log:
> make test
cd "src/modules/perl" && make
make[1]: Entering directory `/software/apa/mod_perl/mod_perl-2.0.10/src/modules/perl'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/software/apa/mod_perl/mod_perl-2.0.10/src/modules/perl'
...
make[1]: Leaving directory `/software/apa/mod_perl/mod_perl-2.0.10/xs'
/usr/bin/perl -Iblib/arch -Iblib/lib \
t/TEST -clean
[warning] setting ulimit to allow core files
ulimit -c unlimited; /usr/bin/perl /software/apa/mod_perl/mod_perl-2.0.10/t/TEST -clean
APACHE_TEST_APXS= APACHE_TEST_GROUP= APACHE_TEST_HTTPD= APACHE_TEST_PORT= APACHE_TEST_USER= \
/usr/bin/perl -Iblib/arch -Iblib/lib \
t/TEST -bugreport -verbose=0
[warning] setting ulimit to allow core files
ulimit -c unlimited; /usr/bin/perl /software/apa/mod_perl/mod_perl-2.0.10/t/TEST -bugreport -verbose=0
/software/apa/apa24/bin/httpd.prefork -d /software/apa/mod_perl/mod_perl-2.0.10/t -f /software/apa/mod_perl/mod_perl-2.0.10/t/conf/httpd.conf -D APACHE2 -D APACHE2_4 -D PERL_USEITHREADS
using Apache/2.4.26 (prefork MPM)
waiting 300 seconds for server to start: .httpd.prefork: Syntax error on line 82 of /software/apa/mod_perl/mod_perl-2.0.10/t/conf/httpd.conf: Cannot load /software/apa/mod_perl/mod_perl-2.0.10/src/modules/perl/mod_perl.so into server: /software/apa/mod_perl/mod_perl-2.0.10/src/modules/perl/mod_perl.so: undefined symbol: mg_free_type
[ error]
server has died with status 255 (t/logs/error_log wasn't created, start the server in the debug mode)
sh: line 1: 3359 Terminated /usr/bin/perl /software/apa/mod_perl/mod_perl-2.0.10/t/TEST -bugreport -verbose=0
make: *** [run_tests] Error 143
This bug was introduced when they added support of perl version 5.22, in mod_perl 2.0.10: https://github.com/apache/mod_perl/commit/82827132efd3c2e25cc413c85af61bb63375da6e#diff-0a249c57fb8151f85647e167a883be1b
And then was fixed in a mod_Perl patch on 4 January 2018 (2.0.11-dev):
https://github.com/apache/mod_perl/commit/f4d886fdf7d79d54a0647336b5623b840a053eab
To fix this problem you must compile from source of this commit of mod_perl 2.0.11-dev (or the trunk version) to fix the problem if you have perl <=5.13.6, or if you can upgrade Perl to version >5.13.6 you can compile with mod_perl 2.0.10.
This change in Perl as been introduced in source of Perl version 5.13.6 in this perl commit :
https://perl5.git.perl.org/perl.git/commit/d908838680ec40ea0e85f59ee66f5f56a225f9b4
The mod_perl fix (in last 2.0.11-dev) in src/modules/perl/modperl_env.c use contextual usage of mg_free to fix the problem :
#if MP_PERL_VERSION_AT_LEAST(5, 13, 6)
mg_free_type((SV*)ENVHV, PERL_MAGIC_env);
#else
mg_free((SV*)ENVHV);
#endif
I solved this by upgrading to Perl 5.14.0 or newer.
In the Perl documentation, mg_free_type first appears in version 5.14.0. You can see under "Magical Functions" where it isn't listed in 5.12.4 but is in 5.14.0
I'm not sure if this is the correct solution as mod_perl2.0 lists Perl 5.6.1 as the minimum version: https://perl.apache.org/docs/2.0/user/install/install.html#item_Perl

How to make DKMS pass the right ARCH to 'make'?

I'm trying to use DKMS to build a module. My problem is that I cannot seem to make DKMS pass the right ARCH to 'make'. It keeps using the architecture of the my OS's kernel which is armv7l. But there's no map
/usr/src/linux/arch/armv7l
It needs to look inside
/usr/src/linux/arch/arm
I have tried passing -a arm, -k 4.4.21-v7+/arm as arguments to 'dkms build', but it doesn't pass that down to 'make'. Adding BUILD_EXCLUSIVE_ARCH="arm" to /usr/src/rtl8812AU-4.3.14/dkms.conf also makes no difference.
sudo dkms build -m ${DRV_NAME} -v ${DRV_VERSION} -k 4.4.21-v7+/arm
Kernel preparation unnecessary for this kernel. Skipping...
Building module:
cleaning build area....
'make'....(bad exit status: 2)
Error! Bad return status for module build on kernel: 4.4.21-v7+ (arm)
Consult /var/lib/dkms/rtl8812AU/4.3.14/build/make.log for more information.
cat /var/lib/dkms/rtl8812AU/4.3.14/build/make.log
DKMS make.log for rtl8812AU-4.3.14 for kernel 4.4.21-v7+ (arm)
Thu Sep 29 16:36:07 UTC 2016
make ARCH=armv7l CROSS_COMPILE= -C /lib/modules/4.4.21-v7+/build M=/var/lib/dkms/rtl8812AU/4.3.14/build modules
make[1]: Entering directory '/usr/src/linux'
Makefile:606: arch/armv7l/Makefile: No such file or directory
make[1]: No rule to make target 'arch/armv7l/Makefile'. Stop.
make[1]: Leaving directory '/usr/src/linux'
Makefile:1576: recipe for target 'modules' failed
make: [modules] Error 2
How to solve this?
Thank you already
I solved this problem on a Raspberry Pi 2 with Ubuntu Mate (16.04) by symlinking the arm directory:
sudo ln -s arm armv7l
Dirty hack, but it works :)
You can pass arch by -a, --arch like this:
dkms install rtl8188fu/1.0 -j 4-a arm
Read more on man page by running man dkms or find it here:
http://manpages.ubuntu.com/manpages/bionic/man8/dkms.8.html

Spark netlib-java BLAS

i am trying to troubleshoot my non-working apache spark and netlib setup and i don't know what to do next.
Here some info:
Spark 1.3.1 (but also tried 1.5.1)
Mesos Cluster with 3 Nodes
Ubuntu Trusty on every node and installed following BLAS package
$ dpkg -l | grep 'blas\|atlas\|lapack'
ii libopenblas-base 0.2.8-6ubuntu1 amd64 Optimized BLAS (linear algebra) library based on GotoBLAS2
$ update-alternatives --get-selections | grep 'blas\|lapack'
libblas.so.3 auto /usr/lib/openblas-base/libblas.so.3
I have built a sample jar for testing if netlib-java can detect this libraries, with following code:
object Main extends App {
println(com.github.fommil.netlib.BLAS.getInstance().getClass().getName())
println(com.github.fommil.netlib.LAPACK.getInstance().getClass().getName())
}
When i execute this code i get following response:
$ java -jar artifacts/BLAStest-assembly-1.0.jar
Mar 29, 2016 3:43:33 PM com.github.fommil.netlib.BLAS <clinit>
WARNING: Failed to load implementation from: com.github.fommil.netlib.NativeSystemBLAS
Mar 29, 2016 3:43:33 PM com.github.fommil.jni.JniLoader liberalLoad
INFO: successfully loaded /tmp/jniloader6790966128222263615netlib-native_ref-linux-x86_64.so
com.github.fommil.netlib.NativeRefBLAS
Mar 29, 2016 3:43:33 PM com.github.fommil.netlib.LAPACK <clinit>
WARNING: Failed to load implementation from: com.github.fommil.netlib.NativeSystemLAPACK
Mar 29, 2016 3:43:33 PM com.github.fommil.jni.JniLoader load
INFO: already loaded netlib-native_ref-linux-x86_64.so
com.github.fommil.netlib.NativeRefLAPACK
So it seems to work just fine here.
But spark can't detect the libraries. I have added this java dependency to my assembly jar
com.github.fommil.netlib:all:1.1.2
also if i try to start a spark shell with this package it doesn't work.
spark-shell --packages com.github.fommil.netlib:all:1.1.2
It looks like your netlib-java implementation is loading the NativeRefBLAS, but not the NativeSystemBLAS. This means that you're inclusion of "com.github.fommil.netlib:all" is working ok, since without it you would be using the non-native F2J implementation. The issue is that you want to use the system-provided BLAS (OpenBLAS), instead of the reference implementation that came with netlib-java. This probably just is a matter of getting the right shared libraries in a location that's visible to your spark executors.
You said that you linked libblas.so.3, but as described in the netlib-java readme, you need to also configure the libblas.so, liblapack.so, and liblapack.so.3:
sudo apt-get install libatlas3-base libopenblas-base
sudo update-alternatives --config libblas.so
sudo update-alternatives --config libblas.so.3
sudo update-alternatives --config liblapack.so
sudo update-alternatives --config liblapack.so.3

Problems to start G-WAN

I try to install G-Wan on Ubuntu 12.04.1 LTS (x64).
I follow the fast instructions: http://gwan.com/download
When i execute $sudo ./gwan, shows me:
Floating point exception (core dumped)
Then i follow the slow instructions: http://www.as2.com/pdf/GWAN-Install-Manual-for-Ubuntu-12.04.pdf
but i have the same error.
I show you the errors of the logs:
apport.log
ERROR: apport (pid 13912) Mon Apr 29 13:42:56 2013: called for pid 13870, signal 8
ERROR: apport (pid 13912) Mon Apr 29 13:42:56 2013: executable: /opt/gwan_linux64-bit/gwan (command line "./gwan")
ERROR: apport (pid 13912) Mon Apr 29 13:42:56 2013: executable does not belong to a package, ignoring
syslog
Apr 29 13:43:48 ip-10-34-153-82 kernel: [1026847.541495] gwan[13914] trap divide error ip:427930 sp:7fff7208d7b8 error:0
Apr 29 13:43:53 ip-10-34-153-82 kernel: [1026852.993012] gwan[13958] trap divide error ip:427930 sp:7fffd2b82468 error:0
Please, Does anyone know what is the problem?
Install the program in my PC (Ubuntu 12.04.2 LTS) and works fine, i don't understand because in my PC works fine and in the server not.
Thanks for all and sorry, my english is bad.
The problem is that some newer versions of hypervisors insist to report ZERO CPU, and/or ZERO CPU Core, leading to a division by zero.
Since G-WAN is optimized for multicore architectures, it queries the CPUID instruction and the OS Kernel structures to check the platform architecture and the associated OS policies (number of online and allowed CPUs).
Other web servers are not affected because they expect users to manually configure and run as many instances as desired (hereby creating the duplicated resource allocations that G-WAN was designed to avoid).
Checking both the CPUID instruction and the Kernel structure was enough, until recently. Now, for any reason, the hypervisors use broken CPUID implementations and OS Kernel structure.
This issue is affecting hosting companies (VPS servers), and Amazon EC2 instances, among others.

Resources