Hi John,
On Thu, Aug 22, 2019 at 08:50:50AM -0700, John Roche wrote:
>this is my catmaid-uwsgi.ini file, what's the correct dir for socket?
On a production system this would likely be somewhere under /run,
because this is typically a tempfs file system, which lives only in
memory. Often times individual tools, like uwsgi, would have their own
folder, which are typically created by the init/service scripts for the
each tool (I think).
Depending on how you run CATMAID, it might be useful though to see
socket and PID files for the relevant components in one location, e.g.
/run/catmaid/. Especially if you also run Celery, Celery Beat, Cache
update worker processes, etc. it is sometimes useful to have all sockets
in one place.
Because /run is not a persistente folder, you want to use a folder like
/run/catmaid/ (or /run/uwsgi/… if you aren't using the regular uwsgi
service, but e.g. supervisord) make sure this folder exists after a
reboot by adding snippets like this to /etc/rc.local, which is executed
on startup:
if [ ! -d /run/catmaid ]; then
mkdir /run/catmaid/
chown www-data:www-data /run/catmaid/
chmod 0755 /run/catmaid/
fi
This assumes you are running all the processes as www-data user.
>root@catmaid:/home/catmaid/django/projects/mysite# cat catmaid-uwsgi.ini
>; uWSGI instance configuration for CATMAID
>[uwsgi]
>virtualenv = /root/.virtualenvs/catmaid/
>chdir = /home/catmaid/django/
>socket = /run/uwsgi/app/catmaid/socket
>mount = /catmaid=/home/catmaid/django/projects/mysite/django.wsgi
>manage-script-name = true
>workers = 2
>threads = 2
>disable-logging = true
In this case the socket file is stored /run/uwsgi/app/catmaid and if you
run uwsgi e.g. through supervisord, you'd need to take care of having
the folder /run/uwsgi/app/catmaid available, by adding sth. like this to
the /etc/rc.local file and excute it as well on a root shell.
if [ ! -d /run/uwsgi/app/catmaid ]; then
mkdir -p /run/uwsgi/app/catmaid
chown -R www-data:www-data /run/uwsgi/
chmod -R 0755 /run/uwsgi/
fi
And I should also updaet the examle uwsgi configuration at some point.
I found myself running uwsgi often also with these settings:
# CATMAID in started in lazy-apps mode, i.e. each worker has a full
# copy of the code in memory. Workers are managed by a master process
# (no emperor).
master = true
lazy-apps = true
# During deploy, old and new master share the same socket. With
# vacuum=true, old master would delete it during shutdown.
vacuum = false
What is also very useful I found is to enable a statistics socket, that
can be used with the extra tool uwsgitop (pip install -U uwsgitop):
# Stats
stats = %(socket-dir)/uwsgi-stats.socket
memory-report = true
>On Thursday, 22 August 2019 16:45:48 UTC+1, John Roche wrote:
>> what is the best way to import files over
What do you mean exactly? I typically would set up stacks and stack
mirrors manually, but the /admin UI has also an importer than can setup
most things for you, if you provide a YAML file. The documentation has
more information here [1].
>> also I'm not 100% sure if I have nginx and the wsgi configured properly...
Uwsgi is very flexible and can be complex to setup, I believe your basic
configuration is ok as long as you make sure the socket directories
exist. The log file is typically helpful if you run into problems. As
written below, the Nginx config looks fine in general.
>> On Wednesday, 7 August 2019 17:25:48 UTC+1, John Roche wrote:
>>> this helped :)
Great!
>>> some of the images are missing though..
The missing image on the front page is probably because you didn't
generate the thumbnail pictures "small.<file-extension>", which is used
there by default. I realize though that the documentation doesn't say
anything about this, but I added a GitHub issue here [2]:
>>> 1. Do you run CATMAID using "manage.py runserver"?
>>> Right now yes, I do want to fix this
Okay, like the documentation suggests, we have most experience running
CATMAID using uWSGI and are pretty happy with it.
>>> 2. Do you run any webserver, e.g. Nginx/Apache/etc. to serve static
>>> files and provide access to CATMAID on port 80?
>>> i am using Nginx.
Okay.
>>> my config for catmaid is
>>>
>>> include /etc/nginx/conf.d/*.conf;
>>> include /etc/nginx/sites-enabled/*;
>>>
>>> upstream catmaid-wsgi {
>>> server
10.28.41.235:8000;
>>> }
>>>
>>> server {
>>> listen 80;
>>> server_name 10.28.41.235;
>>>
>>> # Give access to Django's static files
>>> location /catmaid/static/ {
>>> alias /home/catmaid/django/static/;
>>> }
>>>
>>> location /catmaid/ {
>>> proxy_pass
http://catmaid-wsgi/;
>>> proxy_redirect
http://catmaid-wsgi/ http://$host/;
>>> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
>>> proxy_set_header X-Forwarded-Proto $scheme;
This looks okay in general and should work both with runserver and
uWSGI. If you are using uWSGI though, you can also pass the request
directly to it, rather than using `proxy_pass`, to be slightly more
efficient and use less text:
location /catmaid/ {
include uwsgi_params;
uwsgi_pass unix:///run/uwsgi/app/catmaid/socket;
}
The documentation mentions this on its Production Setup page [3].
Cheers,
Tom
[1]
https://catmaid.readthedocs.io/en/stable/importing_data.html#importing-project-and-stack-information
[2]
https://github.com/catmaid/CATMAID/issues/1916
[3]
https://catmaid.readthedocs.io/en/stable/nginx.html#setup-based-on-nginx-and-uwsgi