uWSGI with pcre support - uwsgi

I installed uWSGI with pcre support (on Heroku)
I got this message :
################# uWSGI configuration #################
pcre = True
kernel = Linux
malloc = libc
execinfo = False
ifaddrs = True
ssl = True
zlib = True
locking = pthread_mutex
plugin_dir = .
timer = timerfd
yaml = embedded
json = False
filemonitor = inotify
routing = True
debug = False
capabilities = False
xml = libxml2
event = epoll
############## end of uWSGI configuration #############
However, when i launch it using uwsgi --pcre-jit
I got this:
*** Starting uWSGI 2.0.10 (64bit) on [Mon Jun 22 22:51:56 2015] ***
compiled with version: 4.8.2 on 22 June 2015 22:37:39
os: Linux-3.13.0-49-generic #83-Ubuntu SMP Fri Apr 10 20:11:33 UTC 2015
nodename: 2bba099f-37e1-4ee2-aaa2-2400a68e6530
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
current working directory: /app
detected binary path: /app/.heroku/python/bin/uwsgi
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 256
your memory page size is 4096 bytes
detected max file descriptor number: 10000
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
The -s/--socket option is missing and stdin is not a socket.
pcre jit disabled. Why uwsgi does not use pcre?

Related

UWSGI Works Within Network But Not Over Domain

I have a RPi running NGINX and UWSGI serving a webpage and an API via UWSGI.
Web page works fine, both locally and from the web.
API works locally, but not via web. My guess it's either the router or the NGINX configuration.
I am using cloudflare for the DNS, and all appears fine there.
I can GET / POST locally using Postman, but not via the web address. I would greatly appreciate any ideas on where to look.
Output from uwsgi is:
*** Starting uWSGI 2.0.20 (32bit) on [Sat May 14 12:35:08 2022] ***
compiled with version: 8.3.0 on 06 October 2021 05:59:48
os: Linux-5.10.103-v7l+ #1529 SMP Tue Mar 8 12:24:00 GMT 2022
nodename: xxx
machine: armv7l
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
current working directory: /var/www/xxx.xxx/public
detected binary path: /home/pi/.local/bin/uwsgi
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 12393
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 http bound on :9090 fd 4
spawned uWSGI http 1 (pid: 3176)
uwsgi socket 0 bound to TCP address 127.0.0.1:34881 (port auto-assigned) fd 3
Python version: 3.7.3 (default, Jan 22 2021, 20:04:44) [GCC 8.3.0]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0xd5c950
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 64408 bytes (62 KB) for 1 cores
*** Operational MODE: single process ***
<<<<<<<<<<<<<<<< Loaded script >>>>>>>>>>>>>>>>
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0xd5c950 pid: 3175 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 3175, cores: 1)

Making Raspberry Pi GPIO work from an Azure IoT Edge Module

I have a simple example Node-RED project here on GitHub where I'm attempting to interact with a few GPIO on a Raspberry Pi running Buster. If I run that project directly on the Pi, it works fine. If I run it as a Module by deploying through Azure IoT Edge, I'm unable to interact with the same GPIO, even if I have deployed using these Container Create Options...
{
"HostConfig": {
"PortBindings": {
"1880/tcp": [
{
"HostPort": "80"
}
]
},
"Privileged": true
}
}
...from /kpmartinhfi/gpio-poc:latest on Docker Hub, built using docker buildx build --platform linux/arm/v7 -t kpmartinhfi/gpio-poc:latest . --push.
The Node-RED editor UI is avialable at :80 on the device, so it's basically working, but attempting to use GPIO gets access/permissions errors:
16 Sep 19:21:33 - [info] Starting flows
16 Sep 19:21:33 - [info] Started flows
16 Sep 19:21:33 - [info] [rpi-gpio out:Buzzer (GPIO20)] err: Traceback (most recent call last):
File "/usr/src/node-red/node_modules/#node-red/nodes/core/hardware/nrgpio.py", line 84, in <module>
:
16 Sep 19:21:33 - [info] [rpi-gpio out:Buzzer (GPIO20)] err: GPIO.setup(pin,GPIO.OUT)
RuntimeError: No access to /dev/mem. Try running as root!
:
16 Sep 19:21:33 - [info] [rpi-gpio out:Relay (GPIO26)] err: Traceback (most recent call last):
File "/usr/src/node-red/node_modules/#node-red/nodes/core/hardware/nrgpio.py", line 84, in <module>
GPIO.setup(pin,GPIO.OUT)
RuntimeError: No access to /dev/mem. Try running as root!
:
16 Sep 19:21:33 - [info] [rpi-gpio out:Buzzer (GPIO20)] closed
16 Sep 19:21:33 - [info] [rpi-gpio out:Relay (GPIO26)] closed
16 Sep 19:21:33 - [info] [rpi-gpio out:Relay (GPIO16)] err: Traceback (most recent call last):
File "/usr/src/node-red/node_modules/#node-red/nodes/core/hardware/nrgpio.py", line 84, in <module>
:
16 Sep 19:21:33 - [info] [rpi-gpio out:Relay (GPIO16)] err: GPIO.setup(pin,GPIO.OUT)
RuntimeError: No access to /dev/mem. Try running as root!
:
16 Sep 19:21:33 - [info] [rpi-gpio out:Relay (GPIO16)] closed
16 Sep 19:21:36 - [info] [rpi-gpio out:Relay (GPIO16)] out: 0
16 Sep 19:21:36 - [error] [rpi-gpio out:Relay (GPIO16)] nrpgio python command not running
16 Sep 19:21:37 - [info] [rpi-gpio out:Relay (GPIO16)] out: 1
16 Sep 19:21:37 - [error] [rpi-gpio out:Relay (GPIO16)] nrpgio python command not running
What's the best way to resolve this that doesn't leave the system in a terribly insecure state?
My attempt at using Privileged:true was meant to be a "hack" just to see things working, but I'm suspecting that that's not a good way to go to "production".
I wonder if I need to do something in the Dockerfile like add the default Node-RED user to a group with access to GPIO, but since each attempt takes quite a while to try, I thought I'd ask first. :)
i'm not sure if this will solve your problem exactly, but one of the things you have to do to get access to the RPI's GPIO pins from your IoT Edge module is to bind them to the module. for example, I wrote a module in python that integrates with the SenseHat accessory for IoT Edge. Like many libraries, it uses the i2c bus to talk to the GPIO pins, so I map those into my container with these "create options"
{"HostConfig":{"Binds":["/dev/i2c-1:/dev/i2c-1"],"Privileged":true}}
If that doesn't work, depending on how Node-Red accesses the pins, you can also try
{"HostConfig":{"Binds":["/dev/gpiomem:/dev/gpiomem"],"Privileged":true}}
or (and I think this is the 'share everything" approach)
{"HostConfig":{"Binds":["/sys:/sys"],"Privileged":true}}

How to fix SIGSEGV which prevents MVC application running in Mono

ASP.NET MVC application is installed in Debian server using Apache and mod_mono.
Trying to start it causes SIGSEGV exception in Mono. Apache error.log contains
[Wed Mar 06 22:07:13 2019] [notice] Apache/2.2.22 (Debian) mod_mono/3.12 configured -- resuming normal operations
Listening on: /tmp/.mod_mono_server4
Root directory: /
Stacktrace:
[Wed Mar 06 22:07:35 2019] [error] (70014)End of file found: read_data failed
[Wed Mar 06 22:07:35 2019] [error] Command stream corrupted, last command was 1
Listening on: /tmp/.mod_mono_server4
Root directory: /
Stacktrace:
Native stacktrace:
/usr/bin/mono() [0x4accca]
/usr/bin/mono() [0x5040fe]
/usr/bin/mono() [0x4275d7]
/lib/x86_64-linux-gnu/libpthread.so.0(+0xf0a0) [0x7f47845d30a0]
/usr/bin/mono() [0x47aad9]
/usr/bin/mono() [0x50fcb8]
/usr/bin/mono() [0x510253]
/usr/bin/mono() [0x425efc]
/usr/bin/mono() [0x4af809]
/usr/bin/mono() [0x4b0117]
[0x411fe68c]
Debug info from gdb:
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
How to fix this so that application can run ?
Same server also contains other application created with older ASP.NET MVC which runs OK.
Mono was installed using Debian package:
mono --version
Mono JIT compiler version 4.6.2 (Stable 4.6.2.7/08fd525 Mon Nov 14 12:30:00 UTC 2016)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: sgen

[uwsgi + lua]: no app loaded

I'm trying to set up a uWSGI server with Lua script.
For now I've just a little test script (more or less the one shown in the uWSGI doc http://uwsgi-docs.readthedocs.org/en/latest/Lua.html#your-first-wsapi-application).
Here is my script :
function run(wsapi_env)
local headers = { ["Content-type"] = "text/html" }
local function hello_text()
coroutine.yield("<html><body>")
coroutine.yield("<p>Hello Wsapi!</p>")
coroutine.yield("<p>PATH_INFO: " .. wsapi_env.PATH_INFO .. "</p>")
coroutine.yield("<p>SCRIPT_NAME: " .. wsapi_env.SCRIPT_NAME .. "</p>")
coroutine.yield("</body></html>")
end
return 200, headers, coroutine.wrap(hello_text)
end
return run
I launch uWSGI with this command line ( until I manage to launch it succefully once, then I will use config file) :
uwsgi --socket :63031 --plugins lua --lua main.lua --master
I've run this command from the directory where is stored main.lua (I've tried with main.lua full path ) .
But uWSGI doesn't load the lua script :
*** Starting uWSGI 2.0.7-debian (64bit) on [Thu Feb 5 15:45:00 2015] ***
compiled with version: 4.9.1 on 25 October 2014 19:17:54
os: Linux-3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt2-1 (2014-12-08)
nodename: ns342653.ip-91-121-135.eu
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
current working directory: /home/vincent/web
detected binary path: /usr/bin/uwsgi-core
your processes number limit is 63906
your memory page size is 4096 bytes
detected max file descriptor number: 65536
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address :63031 fd 3
Initializing Lua environment... (1 lua_States)
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: 8148)
spawned uWSGI worker 1 (pid: 8149, cores: 1)
How can I make uWSGI load my script ?
Thanks for your awnser.
( P.S. : I've successfully launched uWSGI with psgi and perl script with almost the same config)

Passenger/mod_rails fails to initialize in Fedora 12 when starting Apache

I am in the process of setting up a server to run a Ruby on Rails application on Fedora 12, using Passenger.
I am at the stage where I've installed Passenger, set it up as prescribed, but get the following errors when I restart Apache:
[Wed Jan 13 15:41:38 2010] [notice] caught SIGTERM, shutting down
[Wed Jan 13 15:41:40 2010] [notice] SELinux policy enabled; httpd running as context unconfined_u:system_r:httpd_t:s0
[Wed Jan 13 15:41:40 2010] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Wed Jan 13 15:41:40 2010] [error] *** Passenger could not be initialized because of this error: Cannot create FIFO file /tmp/passenger.25235/.guard: Permission denied (13)
[Wed Jan 13 15:41:40 2010] [notice] Digest: generating secret for digest authentication ...
[Wed Jan 13 15:41:40 2010] [notice] Digest: done
[Wed Jan 13 15:41:40 2010] [error] *** Passenger could not be initialized because of this error: Cannot create FIFO file /tmp/passenger.25235/.guard: Permission denied (13)
[Wed Jan 13 15:41:40 2010] [error] python_init: Python version mismatch, expected '2.6', found '2.6.2'.
[Wed Jan 13 15:41:40 2010] [error] python_init: Python executable found '/usr/bin/python'.
[Wed Jan 13 15:41:40 2010] [error] python_init: Python path being used '/usr/lib/python26.zip:/usr/lib/python2.6/:/usr/lib/python2.6/plat-linux2:/usr/lib/python2.6/lib-tk:/usr/lib/python2.6/lib-old:/usr/lib/python2.6/lib-dynload'.
[Wed Jan 13 15:41:40 2010] [notice] mod_python: Creating 4 session mutexes based on 256 max processes and 0 max threads.
[Wed Jan 13 15:41:40 2010] [notice] mod_python: using mutex_directory /tmp
[Wed Jan 13 15:41:40 2010] [notice] Apache/2.2.14 (Unix) DAV/2 Phusion_Passenger/2.2.9 PHP/5.3.0 mod_python/3.3.1 Python/2.6.2 mod_ssl/2.2.14 OpenSSL/1.0.0-fips-beta3 mod_perl/2.0.4 Perl/v5.10.0 configured -- resuming normal operations
As you can see, there is a permissions problem when Passenger is trying to initialize:
[Wed Jan 13 15:41:40 2010] [error] *** Passenger could not be initialized because of this error: Cannot create FIFO file /tmp/passenger.25235/.guard: Permission denied (13)
When Apache is starts, it does create a file in /tmp:
d-ws--x--x. 2 root root 4096 2010-01-13 16:04 passenger.26117
If instead I run the app by firing up mongrel directly with mongrel_rails start -e production, I see the following:
ActiveRecord::StatementInvalid (Mysql::Error: Can't create/write to file '/tmp/#sql_5d3_0.MYI' (Errcode: 13): SHOW FIELDS FROM `users`):
Again the error points to permission issues with the /tmp directory.
I am at a loss as to what the solution is. I'm not sure if it is related to simply directory permissions or Fedora's SELinux security.
Any help would be appreciated. Thanks.
I did the same as Fred, except that instead of doing it one error at a time:
Go into permissive mode by running setenforce 0
Restart apache, and hit your site and use it for a while as normal
Run grep httpd /var/log/audit/audit.log | audit2allow -M passenger
semodule -i passenger.pp
Go back to enforcing mode by running setenforce 1
Restart apache and test your site - hopefully it should all be working as before!
Note that this is basically a specific example of the procedure on the Centos SELinux help - check it out.
I'm having the same issue in CentOS 5.4, SELinux getting in the way of Passenger.
Setting PassengerTempDir to /var/run/passenger simply gives you the same permission errors in the new directory instead of /tmp :
[Mon Feb 22 11:42:40 2010] [error] *** Passenger could not be initialized because of this error: Cannot create directory '/var/run/passenger/passenger.3686'
I can then change the security context of /var/run/passenger to get past this error:
chcon -R -h -t httpd_sys_content_t /var/run/passenger/
...and that lets Passenger create the temp directory, but not files within that directory:
[Mon Feb 22 12:07:06 2010] [error] *** Passenger could not be initialized because of this error: Cannot create FIFO file /var/run/passenger/passenger.3686/.guard: Permission denied (13)
Oddly, re-running the recursive chcon again doesn't get past this error, it keeps dying at this point, and this is where my SELinux knowledge gets murky.
The Phusion Passenger guide sections 6.3.5 and 6.3.7 have some useful thoughts, but they don't seem to completely resolve the problem.
You need more than just the httpd_sys_content_t permission. I use the following technique to get things started:
start a tail on the audit log: tail -f /var/log/audit/audit.log
reload apache: apachectl restart
Go to the /tmp/directory: cd /tmp
If just 1 line is added use the command: tail -1 /var/log/audit/audit.log | audit2allow -M httpdfifo
Note that the name 'httpdfifo' is just a name chosen to reflect the kind of error that has been observed.
This will create a file named 'httpdfifo.pp'. To allow apache to create a FIFO from here on after you have to issue the command: semodule -i httpdfifo.pp
Continue to do this until all audit errors have been resolved (It took 4 different kind of permissions on my system running Centos 5.4)
Running setenforce 0 before starting will let you test if it's SELinux. Don't forget to run setenforce 1 afterwards.
I tried what Dan Sketcher and Fred Appleman suggested, i.e. repeat the following:
yum install setroubleshoot
echo > /var/log/audit/audit.log # clear irrelevant errors
cd ~
service httpd restart # try booting passenger -- audit.log now shows the relevant permission errors
tail -f /var/log/httpd/error_log # check that passenger is still failing due to permission errors
sealert -a /var/log/audit/audit.log > selinux-diag.txt # translate the permission errors
# read and check that you are happy with selinux-diag.txt
# and either follow its specific advice, or if it just wants you to grep into audit2allow, then:
cat /var/log/audit/audit.log | audit2allow -M mypol # grant everything just denied
semodule -i mypol.p # commit new permissions
But after doing this 5 or 6 times, I kept coming up against new errors, and some of the same errors came up even after I had tried to permit them with "audit2allow".
In the end I just turned off SELinux, with:
echo 0 >/selinux/enforce

Resources