uWSGI: implicit plugin requested nolang - python-3.x

Problem
We are using different Python versions with uWSGI since a few days. We managed to make it work. (The websites are running again.) But we get an error in our logs (systemctl status uwsgi-emperor.service):
Loaded: loaded (/etc/uwsgi/uwsgi-emperor.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2019-03-08 06:55:08 CET; 8min ago
Process: 28501 ExecStart=/usr/local/bin/uwsgi_nolang --ini /etc/uwsgi/emperor.ini --emperor-pidfile /run/uwsgi/emperor.pid --plugins-dir /usr/lib/uwsgi/plugins (code=exited, st
Process: 28497 ExecStartPre=/bin/bash -c mkdir -p /run/uwsgi; chown www-data:root /run/uwsgi (code=exited, status=0/SUCCESS)
Main PID: 28505 (uwsgi_nolang)
Status: "The Emperor is governing 5 vassals"
Tasks: 19 (limit: 4915)
Memory: 586.2M
CPU: 1min 1.165s
CGroup: /system.slice/uwsgi-emperor.service
├─28504 /usr/local/bin/uwsgi_nolang --ini /etc/uwsgi/emperor.ini --emperor-pidfile /run/uwsgi/emperor.pid --plugins-dir /usr/lib/uwsgi/plugins
├─28505 /usr/local/bin/uwsgi_nolang --ini /etc/uwsgi/emperor.ini --emperor-pidfile /run/uwsgi/emperor.pid --plugins-dir /usr/lib/uwsgi/plugins
├─28506 /usr/local/bin/uwsgi_nolang --ini /etc/uwsgi/vassals/site1.ini --include /etc/uwsgi/vassals-common.ini
...
systemd[1]: Starting uWSGI Emperor service...
uwsgi_nolang[28501]: [uwsgi] implicit plugin requested nolang
uwsgi_nolang[28501]: open("./nolang_plugin.so"): No such file or directory [core/utils.c line 3724]
uwsgi_nolang[28501]: !!! UNABLE to load uWSGI plugin: ./nolang_plugin.so: cannot open shared object file: No such file or directory !!!
uwsgi_nolang[28501]: [uWSGI] getting INI configuration from /etc/uwsgi/emperor.ini
I couldn't find a nolang_plugin.so anywhere. If you google for it, you get a hand full results only that didn't help.
I also checked that we don't require a plugin = nolang or something similar in our config files. (But in the logs it says that this plugin is requested implicit anyway.)
Installation
Our system Python version is 3.5. I've installed Python 3.6 with pyenv: env CONFIGURE_OPTS="--enable-shared" pyenv install 3.6.8. The --enable-shared is necessary to be able to build a uWSGI plugin with it. (Should I have installed it with env PYTHON_CFLAGS=-fPIC pyenv install 3.6.8 instead as this answer says? Because the error message told me to re-compile Python with these flags but I didn't know about PYTHON_CFLAGS back then.)
Then we followed these official instructions to compile uWSGI and the plugins for Python 3.5 and 3.6.
I.e. compile uWSGI with make PROFILE=nolang and then build the plugins:
./uwsgi --build-plugin "plugins/python python35"
pyenv local 3.6.8
./uwsgi --build-plugin "plugins/python python36"
(We renamed the compiled uwsgi executable to uwsgi_nolang.)
Environment
Debian 4.9.130-2
pyenv 1.2.9
uWSGI 2.0.18
nginx

Related

Problem with a Golang webapp and system service

I am trying to create a Golang server using the gin framework on ubuntu. It works fine when it is executed in the terminal after building it with go build and equally works well locally.
Systemd
Description=goapp
[Service]
Type=simple
Restart=always
RestartSec=5s
ExecStart=/home/.../goapp/main
[Install]
WantedBy=multi-user.target
I got this error
goapp.service - rediate
Loaded: loaded (/lib/systemd/system/goapp.service; disabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Thu 2022-09-29 08:14:10 UTC; 66ms ago
Process: 21628
ExecStart=/home/.../go/goapp/main (code=exited, status=2)
Main PID: 21628 (code=exited, status=2)
CPU: 9ms
Go is compiled language. You need to build your code into an executable binary file using go build command and then give path to binary file to systemd via ExecStart property in unit file.
See Go Documentation and specifically Compile and install the application section to find out more about how to compile your application.
In your example you have ExecStart=/home/.../goapp/main.go which is telling systemd to run source code file. That file is not executable and understood by operating system so it fails to execute and systemd unit fails because of that.
Adding a working directory to the systemd fix this error.
Description=goapp
[Service]
Type=simple
Restart=always
RestartSec=
WorkingDirectory=/home/.../goapp
ExecStart=/home/.../goapp/main
[Install]
WantedBy=multi-user.target

httpd won't start with custom conf files and mod_wsgi built with Python 3.9

I am working on a RedHat Centos 7 box. I have installed python 3.9.2 into a folder under /opt/python3.9. I am in the midst of moving my Django server to production, and have chosen to use Apache (I have installed httpd-devel) with mod_wsgi. I was in the midst of following their instructions to make sure it gets configured correctly.
I installed Apache:
sudo yum install httpd
sudo yum install httpd-devel
then
wget https://github.com/GrahamDumpleton/mod_wsgi/archive/refs/tags/4.9.2.tar.gz
mv 4.9.2.tar.gz ./mod_wsgi_4.9.2.tar.gz
tar xvfz mod_wsgi-4.9.2.tar.gz
cd mod_wsgi*
./configure --with-python=/opt/python3.9/bin/python39
make
sudo make install
all with no errors.
sudo systemctl enable httpd
sudo systemctl start httpd
But as soon as I try to use the demo here (which basically entails adding a conf file to /etc/httpd/conf.d/, called wsgi.conf, and a response file to /var/www/html/, called test_wsgi.py, then restarting Apache), it throws an error and tells me to check journalctl -xe.
Jun 08 21:04:01 ip-172-31-18-8.ec2.internal httpd[11893]: AH00526: Syntax error on line 2 of /etc/httpd/conf.d/wsgi.conf:
Jun 08 21:04:01 ip-172-31-18-8.ec2.internal httpd[11893]: Invalid command 'WSGIScriptAlias', perhaps misspelled or defined by a module not included in the server configuration
Jun 08 21:04:01 ip-172-31-18-8.ec2.internal systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Jun 08 21:04:01 ip-172-31-18-8.ec2.internal systemd[1]: Failed to start The Apache HTTP Server.
-- Subject: Unit httpd.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit httpd.service has failed.
--
-- The result is failed.
Jun 08 21:04:01 ip-172-31-18-8.ec2.internal systemd[1]: Unit httpd.service entered failed state.
Jun 08 21:04:01 ip-172-31-18-8.ec2.internal systemd[1]: httpd.service failed.
Jun 08 21:04:01 ip-172-31-18-8.ec2.internal sudo[11888]: pam_unix(sudo:session): session closed for user root
I am 95% certain that if I did what was suggested here that it would compile mod_wsgi for Python 2.7 and I don't want to use python2.7... that's why I compiled mod_wsgi for python 3.9.2.
If I try to use my django.conf file instead of the one I linked in the demo, I get a different error that might be more helpful for the slue:
httpd.conf: Syntax error on line 3 of /etc/httpd/conf.d/django.conf: Cannot load /usr/lib64/httpd/modules/mod_wsgi.so into server: libpython3.9.so.1.0: cannot open shared object file: No such file or directory
Line 3 is:
LoadModule wsgi_module /usr/lib64/httpd/modules/mod_wsgi.so
Output of ldd /usr/lib64/httpd/modules/mod_wsgi.so:
[ec2-user#ip-172-31-18-8 ~]$ ldd /usr/lib64/httpd/modules/mod_wsgi.so
linux-vdso.so.1 (0x00007ffd7b50d000)
libpython3.9.so.1.0 => /opt/python39/lib/libpython3.9.so.1.0 (0x00007ff0ebf85000)
libcrypt.so.1 => /lib64/libcrypt.so.1 (0x00007ff0ebd4e000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007ff0ebb30000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007ff0eb92c000)
libutil.so.1 => /lib64/libutil.so.1 (0x00007ff0eb729000)
libm.so.6 => /lib64/libm.so.6 (0x00007ff0eb3e9000)
libc.so.6 => /lib64/libc.so.6 (0x00007ff0eb03e000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff0ec781000)
I can verify that /opt/python39/lib/libpython3.9.so.1.0 exists and I have it in my LD_RUN_PATH and LD_LIBRARY_PATH variables
Output of sudo apachectl -V:
Server version: Apache/2.4.53 ()
Server built: Apr 12 2022 12:00:44
Server's Module Magic Number: 20120211:124
Server loaded: APR 1.7.0, APR-UTIL 1.6.1, PCRE 8.32 2012-11-30
Compiled using: APR 1.7.0, APR-UTIL 1.6.1, PCRE 8.32 2012-11-30
Architecture: 64-bit
Server MPM: prefork
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_PROC_PTHREAD_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=256
-D HTTPD_ROOT="/etc/httpd"
-D SUEXEC_BIN="/usr/sbin/suexec"
-D DEFAULT_PIDLOG="/run/httpd/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"
You are seeing this error...
libpython3.9.so.1.0: cannot open shared object file: No such file or directory
...because httpd has no idea it's supposed to look in /opt/python3.9/lib to find the necessary shared library. There are several ways of resolving this problem:
Set -rpath when linking the module.
This embeds a path to the library in the compiled binary. You would set it by running make like this inside the mod_wsgi-4.9.2 directory:
make LDFLAGS='-L/opt/python3.9/lib -Wl,-rpath,/opt/python3.9/lib'
Set LD_LIBRARY_PATH in httpd's environment. This provides
httpd with an additional list of directories to search for shared
libraries. We can test it like this:
LD_LIBRARY_PATH=/opt/python3.9/lib httpd -DFOREGROUND
To set it persistently, you'd want to customize the httpd
service unit:
Run systemctl edit httpd
In the editor that comes up, add the following content:
[Service]
Environment=LD_LIBRARY_PATH=/opt/python3.9/lib
This creates
/etc/systemd/system/httpd.service.d/override.conf.
Run systemctl daemon-reload to refresh the cached version of the unit file.
Restart your httpd service.
Edit the global library search path by creating
/etc/ld.so.conf.d/python3.9.conf with the following content:
/opt/python3.9/lib
Then run:
ldconfig
Any of the above options should get things running for you.

Falcon sensor fails to start the agent

I am trying to install falcon-sensor(version:4.16.0) on a Debian machine. When I try to start the agent it doesn't start up.
I checked the logs of falcon-sensor and here is what it says :
2019 unable to initialize dynamic libraries. (2309) [144]
I checked the log of falconctl and here is what it says :
Invalid file /opt/CrowdStrike/falconstore length: 0 (2277) [568]
I tried finding answers through googling but I could not find any.
Any help on this would be really helpful
Thanks in advance.
falcon-sensor has libssl.so.1.0.0 as dependency, but that version is missing on Debian Stretch (there is version 1.0.2).
I just created a symlink to the existing version:
ln -s libssl.so.1.0.2 /usr/lib/x86_64-linux-gnu/libssl.so.1.0.0
and now it works.
Make sure you performed the basic steps correctly:
1 ) Download falcon-sensor.rpm to your machine.
2 ) sudo yum install -y falcon-sensor.rpm .
3 ) sudo /opt/CrowdStrike/falconctl -s --cid=<Your-CID> .
4 ) service falcon-sensor start.
Check status:
[ec2-user#ip-172-21-80-18 ~]$ service falcon-sensor status
Redirecting to /bin/systemctl status falcon-sensor.service
● falcon-sensor.service - CrowdStrike Falcon Sensor
Loaded: loaded (/usr/lib/systemd/system/falcon-sensor.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2020-09-05 13:48:34 UTC; 1min 6s ago
Process: 2746 ExecStart=/opt/CrowdStrike/falcond (code=exited, status=0/SUCCESS)
Process: 2729 ExecStartPre=/opt/CrowdStrike/falconctl -g --cid (code=exited, status=0/SUCCESS)
Main PID: 2747 (falcond)
Tasks: 19
Memory: 4.5M
CGroup: /system.slice/falcon-sensor.service
├─2747 /opt/CrowdStrike/falcond
└─2749 falcon-sensor
systemd[1]: Starting CrowdStrike Falcon Sensor...
falconctl[2729]: cid="<Your-CID>".
falcond[2747]: starting
Started CrowdStrike Falcon Sensor.
falcon-sensor[2749]: No traceLevel set via falconctl defaulting to none
falcon-sensor[2749]: LogLevelUpdate: none = trace level 0.
View process:
ps -e | grep falcon-sensor
2749 ? 00:00:00 falcon-sensor
Notice that all commands should be executed with sudo Or else you see the error below:
$ service falcon-sensor restart #< --- No root permission
Redirecting to /bin/systemctl restart falcon-sensor.service
Failed to restart falcon-sensor.service: The name org.freedesktop.PolicyKit1 was not provided by any .service files
See system logs and 'systemctl status falcon-sensor.service' for details.
I follow install steps 1~3 below without issue, but have not get a CID, please let met know how to get it
1 ) Download falcon-sensor.rpm to your machine.
2 ) sudo yum install -y falcon-sensor.rpm .
3 ) sudo /opt/CrowdStrike/falconctl -s --cid=<Your-CID>
4 ) service falcon-sensor start.

Auto-start service for systemd: Invalid Argument

I am trying to start service at startup. My service should start .exe file with mono.
When I try to just run it with:
sudo systemctl start myservice.service
Everything goes okay and my app is running. However when i run status for service i get "bad;" for Systemd Unit files status.
sudo systemctl status myservice.service
● myservice.service
Loaded: loaded (/etc/systemd/system/myservice.service; bad; vendor preset: enabled)
Active: active (running) since Ut 2017-03-21 12:01:05 CET; 2s ago
Main PID: 3892 (mono)
CGroup: /system.slice/myservice
└─3892 /usr/bin/mono /opt/myapp/myapp.exe
When i run enable command i get:
sudo systemctl enable myservice.service
Failed to execute operation: Invalid argument
My unit file /etc/systemd/system/myservice.service contains:
[Unit]
Description=myservice
After=network.target
[Service]
ExecStart=/usr/bin/mono /opt/myapp/myapp.exe
WorkingDirectory=/opt/myapp
Restart=on-failure
[Install]
WantedBy=multi-user.target
Can anyone help me with this?.. thank you..
I working on Ubuntu:
Distributor ID: Ubuntu
Description: Ubuntu 16.04.2 LTS
Release: 16.04
Codename: xenial
Mono:
sudo mono --version
Mono JIT compiler version 4.8.0 (Stable 4.8.0.495/e4a3cf3 Wed Feb 22 18:25:42 UTC 2017)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: x86
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: sgen

Jenkins fails to start on centOS7

I am using jenkins on my centOS7/linux server. When I start jenkins and checked the status it showed me like this.
>jenkins.service - Jenkins Service
> Loaded: loaded (/etc/systemd/system/jenkins.service; enabled; vendor preset: > disabled)
> Active: failed (Result: exit-code) since Mon 2017-02-20 22:52:19 PST; 22s > ago
> Process: 40251 ExecStart=/usr/bin/java -jar /usr/local/bin/jenkins.war
>(code=exited, status=1/FAILURE)
> Main PID: 40251 (code=exited, status=1/FAILURE)
>Feb 20 22:52:19 CentOS7 systemd[1]: Started Jenkins Service.
>Feb 20 22:52:19 CentOS7 systemd[1]: Starting Jenkins Service...
>Feb 20 22:52:19 CentOS7 java[40251]: Error: Unable to access jarfile >/usr/l...ar
>Feb 20 22:52:19 CentOS7 systemd[1]: jenkins.service: main process exited, >c...RE
>Feb 20 22:52:19 CentOS7 systemd[1]: Unit jenkins.service entered failed state.
>Feb 20 22:52:19 CentOS7 systemd[1]: jenkins.service failed.
>Hint: Some lines were ellipsized, use -l to show in full.
So I uninstalled the jenkins sudo yum remove jenkins by this command, and installed it again sudo yum install jenkins.
Now again facing the same issue.
Can anyone tell me what to do.
Thanks!!
Before you can install Jenkins, you need to setup a Java virtual machine on your system
yum install java-1.8.0-openjdk.x86_64
And set two environment variables: JAVA_HOME and JRE_HOME.
echo 'export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk' | sudo tee -a /etc/profile
echo 'export JRE_HOME=/usr/lib/jvm/jre' | sudo tee -a /etc/profile
source /etc/profile
Then install jenkins and allow inbound traffic on port 8080.
You can see more details from how to install jenkins on Centos 7.
Hope this helps.
As per Jun, Jenkins required Java 11.
Refer :
Required Java version for Jenkins
at first you cannot get clue, on run systemctl status jenkins.service
until I try to change JENKINS_USER on /etc/init.d/jenkins to root, and show me
Jenkins requires Java versions [17, 11] but you are running with Java 1.8 from /usr/lib/j
Once I upgraded Java to 11 then it started working.

Resources