Uwsgi emperor has no vassals - linux

I am trying to set up nginx to work with uwsgi, I am on Arch Linux. I have /etc/uwsgi/emperor.ini and /etc/uwsgi/vassals/myapp.ini. My emperor.ini looks like:
[uwsgi]
emperor = /etc/uwsgi/vassals
emperor-pidfile = /run/uwsgi/uwsgi.pid
uid = http
gid = http
logto = /var/log/uwsgi/uwsgi.log
myapp.ini
[uwsgi]
chdir = /srv/http/myapp/src/
wsgi-file = run.py
callable = app
processes = 4
threads = 2
offload-threads = 2
stats = 127.0.0.1:9191
max-requests = 5000
master = True
vacuum = True
socket = 127.0.0.1:3031
enable-threads = true
harakiri = 60
logto = /var/log/uwsgi/myapp.log
uwsgi.service [for systemd]
[Unit]
Description=uWSGI Emperor
After=syslog.target
[Service]
PIDFile=/run/uwsgi/uwsgi.pid
ExecStartPre=/bin/mkdir -p /run/uwsgi
ExecStartPre=/bin/chown http:http /run/uwsgi
ExecStart=/usr/bin/uwsgi --ini /etc/uwsgi/emperor.ini
Restart=always
Type=notify
StandardError=syslog
NotifyAccess=main
[Install]
WantedBy=multi-user.target
Yet when the uwsgi.service runs I get:
uwsgi.service - uWSGI Emperor
Loaded: loaded (/etc/systemd/system/uwsgi.service; disabled)
Active: active (running) since Sun 2014-02-02 04:37:04 PST; 34min ago
Process: 31537 ExecStartPre=/bin/chown http:http /run/uwsgi (code=exited, status=0/SUCCESS)
Process: 31535 ExecStartPre=/bin/mkdir -p /run/uwsgi (code=exited, status=0/SUCCESS)
Main PID: 31540 (uwsgi)
Status: "The Emperor is governing 0 vassals"
CGroup: /system.slice/uwsgi.service
ââ31540 /usr/bin/uwsgi --ini /etc/uwsgi/emperor.ini
Feb 02 04:37:04 MyMachine uwsgi[31540]: [uWSGI] getting INI configuration from /etc/uwsgi/emperor.ini
Feb 02 04:37:04 MyMachine systemd[1]: Started uWSGI Emperor.
That bit right there? "The Emperor is governing 0 vassals" for some reason it will not look at the myapp.ini in the vassal directory. This is what I get in a command line "log":
*** Starting uWSGI 2.0 (64bit) on [Sun Feb 2 05:27:37 2014] ***
compiled with version: 4.8.2 20131219 (prerelease) on 09 January 2014 11:43:55
os: Linux-3.12.7-2-ARCH #1 SMP PREEMPT Sun Jan 12 13:09:09 CET 2014
nodename: MyMachine
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 2
current working directory: /home/me
detected binary path: /usr/bin/uwsgi
your processes number limit is 26743
your memory page size is 4096 bytes
*** WARNING: you have enabled harakiri without post buffering. Slow upload could be rejected on post-unbuffered webservers ***
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 TCP address 127.0.0.1:3031 fd 3
Python version: 2.7.6 (default, Nov 26 2013, 12:52:49) [GCC 4.8.2]
Python main interpreter initialized at 0xcfd340
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 415280 bytes (405 KB) for 8 cores
*** Operational MODE: preforking+threaded ***
WSGI app 0 (mountpoint='') ready in 2 seconds on interpreter 0xcfd340 pid: 32089 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 32089)
spawned uWSGI worker 1 (pid: 32092, cores: 2)
spawned 2 offload threads for uWSGI worker 1
spawned uWSGI worker 2 (pid: 32095, cores: 2)
spawned uWSGI worker 3 (pid: 32097, cores: 2)
spawned 2 offload threads for uWSGI worker 3
spawned uWSGI worker 4 (pid: 32100, cores: 2)
spawned 2 offload threads for uWSGI worker 2
spawned 2 offload threads for uWSGI worker 4
I cannot seem to get uwsgi to run see its vassals no matter what I do. Thanks.
EDIT
OK so I decided to go back to the command line so I don't have to deal with log and pid permission errors and I noticed something strange. When I make write out uwsgi --ini /etc/uwsgi/emperor.ini the entire thing works, I can access the site through nginx, beautiful, but I saw this in the console output:
*** Starting uWSGI 2.0 (64bit) on [Sun Feb 2 15:19:43 2014] ***
compiled with version: 4.8.2 20131219 (prerelease) on 09 January 2014 11:43:55
os: Linux-3.12.9-2-ARCH #1 SMP PREEMPT Fri Jan 31 10:22:54 CET 2014
nodename: MyMachine
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 2
current working directory: /home/me
detected binary path: /usr/bin/uwsgi
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 26743
your memory page size is 4096 bytes
detected max file descriptor number: 1024
*** starting uWSGI Emperor ***
*** has_emperor mode detected (fd: 5) ***
[uWSGI] getting INI configuration from /etc/uwsgi/emperor.ini
*** Starting uWSGI 2.0 (64bit) on [Sun Feb 2 15:19:43 2014] ***
compiled with version: 4.8.2 20131219 (prerelease) on 09 January 2014 11:43:55
os: Linux-3.12.9-2-ARCH #1 SMP PREEMPT Fri Jan 31 10:22:54 CET 2014
nodename: MyMachine
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 2
current working directory: /home/me
detected binary path: /usr/bin/uwsgi
your processes number limit is 26743
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)
*** starting uWSGI sub-Emperor ***
Python version: 2.7.6 (default, Nov 26 2013, 12:52:49) [GCC 4.8.2]
*** has_emperor mode detected (fd: 7) ***
[uWSGI] getting INI configuration from myapp.ini
*** Starting uWSGI 2.0 (64bit) on [Sun Feb 2 15:19:43 2014] ***
compiled with version: 4.8.2 20131219 (prerelease) on 09 January 2014 11:43:55
os: Linux-3.12.9-2-ARCH #1 SMP PREEMPT Fri Jan 31 10:22:54 CET 2014
nodename: MyMachine
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 2
current working directory: /etc/uwsgi/vassals
detected binary path: /usr/bin/uwsgi
your processes number limit is 26743
your memory page size is 4096 bytes
*** WARNING: you have enabled harakiri without post buffering. Slow upload could be rejected on post-unbuffered webservers ***
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 TCP address 127.0.0.1:3031 fd 3
Python version: 2.7.6 (default, Nov 26 2013, 12:52:49) [GCC 4.8.2]
*** Python threads support is disabled. You can enable it with --enable-threads ***
Python main interpreter initialized at 0x2403ab0
your mercy for graceful operations on workers is 60 seconds
*** Operational MODE: no-workers ***
spawned uWSGI master process (pid: 1640)
Sun Feb 2 15:19:43 2014 - [emperor] vassal /etc/uwsgi/emperor.ini has been spawned
Python main interpreter initialized at 0x17682a0
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 415280 bytes (405 KB) for 8 cores
*** Operational MODE: preforking+threaded ***
WSGI app 0 (mountpoint='') ready in 2 seconds on interpreter 0x17682a0 pid: 1642 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 1642)
Sun Feb 2 15:19:45 2014 - [emperor] vassal myapp.ini has been spawned
spawned uWSGI worker 1 (pid: 1645, cores: 2)
spawned 2 offload threads for uWSGI worker 1
spawned uWSGI worker 2 (pid: 1648, cores: 2)
Sun Feb 2 15:19:45 2014 - [emperor] vassal myapp.ini is ready to accept requests
spawned 2 offload threads for uWSGI worker 2
spawned uWSGI worker 3 (pid: 1651, cores: 2)
spawned 2 offload threads for uWSGI worker 3
spawned uWSGI worker 4 (pid: 1657, cores: 2)
*** Stats server enabled on 127.0.0.1:9191 fd: 16 ***
spawned 2 offload threads for uWSGI worker 4
[pid: 1648|app: 0|req: 1/1] 192.168.1.156 () {40 vars in 795 bytes} [Sun Feb 2 15:20:40 2014] GET /articles => generated 2943 bytes in 164 msecs (HTTP/1.1 200) 3 headers in 283 bytes (1 switches on core 0)
announcing my loyalty to the Emperor...
Sun Feb 2 15:20:40 2014 - [emperor] vassal myapp.ini is now loyal
[pid: 1657|app: 0|req: 1/2] 192.168.1.156 () {40 vars in 792 bytes} [Sun Feb 2 15:20:41 2014] GET /index => generated 3216 bytes in 184 msecs (HTTP/1.1 200) 3 headers in 283 bytes (1 switches on core 0)
announcing my loyalty to the Emperor...
Sun Feb 2 15:20:42 2014 - [emperor] vassal myapp.ini is now loyal
I started noticing some odd ball behavior in the output. I finally came down to this configuration which let's me see my site.
emperor.ini
[uwsgi]
emperor = /etc/uwsgi/vassals
master = true
#gid = http
#uid = http
I commented out the gid and uid because with them there I get a bad gateway response when I try to connect to my website, it warns me about it in the log uWSGI running as root, you can use --uid/--gid/--chroot options but I am not sure what to do about it.
myapp.ini
[uwsgi]
chdir = /srv/http/myapp/src/
wsgi-file = run.py
callable = app
processes = 4
threads = 2
offload-threads = 2
stats = 127.0.0.1:9191
max-requests = 5000
master = true
vacuum = true
socket = 127.0.0.1:3031
harakiri = 60
uwsgi.service
[Unit]
Description=uWSGI Emperor
After=syslog.target
[Service]
ExecStart=/usr/bin/uwsgi --ini /etc/uwsgi/emperor.ini --enable-threads
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=main
[Install]
WantedBy=multi-user.target
No idea what to do about it running as root.

create a vassals in /etc/uwsgi/vassals/

Related

504-loadbalancer error. Website hangs when ML model is run by only one user

I think my webapp is pretty cool. It's a natural language playlist generator. It takes in a description of a playlist, like:
"midwest emo songs to cry to in the shower because my girlfriend broke up with me"
and converts it into an embedding generated by a NLP transformer model (specifically SentenceTransformers) and does recommender system stuff to return songs in a playlist for a user.
My website hangs after the user has submitted their description, and I get a 504 load balancer error after 5 minutes. After tracing where the code hangs, it seems to stop during model.encode(text), which runs the user's query through the ML model to get the embedding.
This code runs no problem on my local machine, and when I run it in the console it also has no problem processing the text through the ML model.
What should I do? Add more workers? Free up space in the program? Let me know.
Below are my server logs after model.encode() is run.
2022-11-26 07:53:26 entered the get embedding function
2022-11-26 07:53:27 announcing my loyalty to the Emperor...
2022-11-26 07:54:11 Sat Nov 26 07:54:10 2022 - HARAKIRI ON WORKER 4 (pid: 18, try: 1)
2022-11-26 07:54:11 Sat Nov 26 07:54:10 2022 - HARAKIRI !!! worker 4 status !!!
2022-11-26 07:54:11 Sat Nov 26 07:54:10 2022 - HARAKIRI [core 0] 10.0.0.75 - POST / since 1669448649
2022-11-26 07:54:11 Sat Nov 26 07:54:10 2022 - HARAKIRI !!! end of worker 4 status !!!
2022-11-26 07:54:11 DAMN ! worker 4 (pid: 18) died, killed by signal 9 :( trying respawn ...
2022-11-26 07:54:11 Respawned uWSGI worker 4 (new pid: 33)
2022-11-26 07:54:11 spawned 2 offload threads for uWSGI worker 4
2022-11-26 08:03:28 Sat Nov 26 08:03:27 2022 - HARAKIRI ON WORKER 3 (pid: 15, try: 1)
2022-11-26 08:03:28 Sat Nov 26 08:03:27 2022 - HARAKIRI !!! worker 3 status !!!
2022-11-26 08:03:28 Sat Nov 26 08:03:27 2022 - HARAKIRI [core 0] 10.0.0.75 - POST / since 1669449206
2022-11-26 08:03:28 Sat Nov 26 08:03:27 2022 - HARAKIRI !!! end of worker 3 status !!!
2022-11-26 08:03:28 DAMN ! worker 3 (pid: 15) died, killed by signal 9 :( trying respawn ...
2022-11-26 08:03:28 Respawned uWSGI worker 3 (new pid: 36)
2022-11-26 08:03:28 spawned 2 offload threads for uWSGI worker 3
I tried running this code in the console of pythonanywhere, and it ran just fine. I'm stuck!
I used an always on task to run the queries through the model and spit them back into the main script.
Works like a dream!

Unable to load app 0 (mountpoint='') (callable not found or import error)

I have the below error with nginx uWSGI Flask application on CentOS 7 Linux:
unable to load app 0 (mountpoint='') (callable not found or import error)
I have followed Digital Ocean tut as my first time with Linux, after original Udemy tut using earlier Centos version didnt seem to work. I was able to get 'Hello world' type basic Python file to run on uwsgi and nginx following the tut, then I see several people have this error but seem different solutions. I changed permissions recursively on a parent folder above the app as I thought permissions might be source of error:
sudo chmod -R 771 www
and also giving nginx access to ?my user group? as Dig Ocean tutorial advised:
sudo usermod -a -G will nginx
chmod 710 /home/will
uwsgi.ini file is following, where /var/www/html/CON29Application1/Source/app.py is the app I want to run, not sure if module line is correct syntax:
[uwsgi]
module = Source.app
master = true
socket = /var/www/html/CON29Application1/socket.sock
chmod-socket = 777
vacuum = true
processes = 8
threads = 8
harakiri = 15
logto = /var/www/html/CON29Application1/log/%n.log
die-on-term = true
Systemd file is this at /etc/systemd/system/CON29Application1.service:
[Unit]
Description=uWSGI instance to serve CON29Application1
After=network.target
[Service]
User=will
Group=nginx
WorkingDirectory=/var/www/html/CON29Application1
Environment="PATH=/var/www/html/CON29Application1/venv/bin"
ExecStart=/var/www/html/CON29Application1/venv/bin/uwsgi --ini uwsgi.ini
[Install]
WantedBy=multi-user.target
This is default.conf file at /etc/nginx/conf.d/default.conf (server IP I blanked in this post for security reasons):
server {
listen 80;
server_name 188.xxx.xxx.xxx;
location / {
include uwsgi_params;
uwsgi_pass unix:/var/www/html/CON29Application1/socket.sock;
uwsgi_modifier1 30;
}
error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
and this is app.py file:
from flask import Flask, render_template
...
app = Flask(__name__)
app.config.from_object('Source.config')
app.secret_key = "---------------------------------"
...
And sorry as I am not that sure which files are relevant to include, so here is also the full uwsgi.log file! Thanks for any ideas:
*** Starting uWSGI 2.0.15 (64bit) on [Wed Oct 4 13:26:19 2017] ***
compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-16) on 02 October 2017 21:47:33
os: Linux-3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017
nodename: CON29Application1
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /var/www/html/CON29Application1
detected binary path: /var/www/html/CON29Application1/venv/bin/uwsgi
your processes number limit is 1792
your memory page size is 4096 bytes
*** WARNING: you have enabled harakiri without post buffering. Slow upload could be rejected on post-unbuffered webservers ***
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 /var/www/html/CON29Application1/socket.sock fd 3
Python version: 3.6.2 (default, Sep 27 2017, 16:30:17) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
Python main interpreter initialized at 0x9acbd0
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 1304064 bytes (1273 KB) for 64 cores
*** Operational MODE: preforking+threaded ***
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 24254)
spawned uWSGI worker 1 (pid: 24259, cores: 8)
spawned uWSGI worker 2 (pid: 24260, cores: 8)
spawned uWSGI worker 3 (pid: 24261, cores: 8)
spawned uWSGI worker 4 (pid: 24262, cores: 8)
spawned uWSGI worker 5 (pid: 24263, cores: 8)
spawned uWSGI worker 6 (pid: 24264, cores: 8)
spawned uWSGI worker 7 (pid: 24265, cores: 8)
spawned uWSGI worker 8 (pid: 24266, cores: 8) 

cgconfig service won't start up

I have already referenced this post: Centos cgconfig fails to start
I have a centos 7 machine. I've tried commenting out and leaving in memory in the following /etc/cgconfig.conf file:
mount {
cpuset = /cgroup/cpuset;
cpu = /cgroup/cpu;
cpuacct = /cgroup/cpuacct;
memory = /cgroup/memory;
devices = /cgroup/devices;
freezer = /cgroup/freezer;
net_cls = /cgroup/net_cls;
blkio = /cgroup/blkio;
}
I've also manually created that directory structure. When I run service cgconfig start, systemctl status cgconfig.service gives me this:
cgconfig.service - Control Group configuration service
Loaded: loaded (/usr/lib/systemd/system/cgconfig.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Tue 2017-03-14 20:27:40 EDT; 18s ago
Process: 6713 ExecStart=/usr/sbin/cgconfigparser -l /etc/cgconfig.conf -L /etc/cgconfig.d -s 1664 (code=exited, status=101)
Main PID: 6713 (code=exited, status=101)
Mar 14 20:27:40 localhost.localdomain systemd[1]: Starting Control Group configuration service...
Mar 14 20:27:40 localhost.localdomain cgconfigparser[6713]: /usr/sbin/cgconfigparser; error loading /etc/cgconfig.conf: Cgroup mounting failed
Mar 14 20:27:40 localhost.localdomain cgconfigparser[6713]: Error: cannot mount cpu to /cgroup/cpu: Device or resource busy
Mar 14 20:27:40 localhost.localdomain systemd[1]: cgconfig.service: main process exited, code=exited, status=101/n/a
Mar 14 20:27:40 localhost.localdomain systemd[1]: Failed to start Control Group configuration service.
Mar 14 20:27:40 localhost.localdomain systemd[1]: Unit cgconfig.service entered failed state.
Mar 14 20:27:40 localhost.localdomain systemd[1]: cgconfig.service failed.
I've also tried to look at /proc/mounts to perhaps unmount cpu.
Any help to get the cgconfig service to start would be helpful.
$ lssubsys -a
cpu,cpuacct
If is a cosubsystem like 'cpu,cpuacct', must mount in the same hierachy (for cg).
Running on Ubuntu I could resolve the same issue by installing the libcgmanager which provides the daemon cgmanager.

CentOS 7 - boot order needs to be changed in order for sge to start automatically

It seems like sge tries start before lustre is mounted when the server boots, which brings an error to start automatically when it reboots.
Can somebody tell me how to change the order when it boots, so sge starts after lustre is mounted?
Error message from the log:
Aug 12 11:46:21 dragen1 systemd: Configuration file /usr/lib/systemd/system/sge_execd.service is marked executable. Please remove executable permission bits. Proceeding anyway.
Aug 12 11:46:40 dragen1 sge_execd: error: SGE_ROOT directory "/cm/shared/apps/sge/2011.11p1" doesn't exist
Aug 12 11:46:40 dragen1 systemd: sge_execd.service: control process exited, code=exited status=1
Aug 12 11:46:40 dragen1 systemd: Unit sge_execd.service entered failed state.
Aug 12 11:46:40 dragen1 systemd: sge_execd.service failed
I added in the following under [Unit] from the sge service
RequiresMountsFor=(Mount Point)
This fixed the problem.

How to enable guake at startup using systemd

i made my service
/etc/systemd/system/guake.service
containing
[Unit]
Description=Start guake
[Service]
ExecStart=/bin/bash guake
[Install]
WantedBy=graphical.target
then i did
systemctl start guake.service
systemctl status guake.service
but i get
● guake.service - Start guake
Loaded: loaded (/etc/systemd/system/guake.service; enabled; vendor preset: disabled)
Active: failed (Result: core-dump) since Thu 2015-07-16 21:14:36 SAST; 4s ago
Process: 10785 ExecStart=/bin/bash guake (code=dumped, signal=SEGV)
Main PID: 10785 (code=dumped, signal=SEGV)
Jul 16 21:14:36 tawanda-pc bash[10785]: /usr/lib/python2.7/site-packages/gtk-2.0/gtk/init.py:57: GtkWarning: could...isplay
Jul 16 21:14:36 tawanda-pc bash[10785]: warnings.warn(str(e), _gtk.Warning)
Jul 16 21:14:36 tawanda-pc bash[10785]: /usr/lib/python2.7/site-packages/keybinder/init.py:26: GtkWarning: IA__gdk...failed
Jul 16 21:14:36 tawanda-pc bash[10785]: from _keybinder import *
Jul 16 21:14:36 tawanda-pc bash[10785]: /usr/lib/python2.7/site-packages/keybinder/init.py:26: GtkWarning: IA__gdk...failed
Jul 16 21:14:36 tawanda-pc bash[10785]: from _keybinder import *
Jul 16 21:14:36 tawanda-pc systemd[1]: guake.service: Main process exited, code=dumped, status=11/SEGV
Jul 16 21:14:36 tawanda-pc systemd[1]: guake.service: Unit entered failed state.
Jul 16 21:14:36 tawanda-pc systemd[1]: guake.service: Failed with result 'core-dump'.
Jul 16 21:14:36 tawanda-pc systemd-coredump[10790]: Process 10785 (python2) of user 0 dumped core.
Hint: Some lines were ellipsized, use -l to show in full.
I also tried setting WantedBy=multi-user.target but it has the same error
i am runnig arch linux, how do i get this to startup, thanks all
systemctl enable guake.service
cf https://wiki.debian.org/systemd

Resources