Forum

MayanEDMS (uwsgi + Python + Hiawatha) ?!

Thom
11 September 2016, 17:59
I think, I need some help here.

I'm about to install MayanEDMS http://mayan.readthedocs.io/ on Hiawatha https://www.hiawatha-webserver.org/

I could run the the test environment (http://mayan.readthedocs.io/en/latest/topics/installation.html) on ArchLinux's by doing http://gitlab.com/mayan-edms/mayan-edms/issues/318. So far so good, now the deployment approach:

Switching to deployment installation I got into trouble. Though it seems I got the *uwsgi-socket* running now, I still have some issues:

1. When visiting the FQDN (dms.myhost.localdomain) of my page nothing happens. Which is quite logical, as I changed my settings according to https://www.hiawatha-webserver.org/forum/topic/2389/#12001
FastCGIserver {
FastCGIid = MAYAN
ConnectTo = /usr/share/mayan-edms/uwsgi.sock
Extension = py
SessionTimeout = 30
}
UrlToolkit {
ToolkitID = dms
Match ^/dms(/static/*) Rewrite $1
Match ^/$ Rewrite /dms
}
UrlToolkit {
ToolkitID = storage
Match ^/dms(/document_storage/*) Rewrite $1
Match ^/$ Rewrite /dms
}
UrlToolkit {
ToolkitID = cache
Match ^/dms(/document_cache/*) Rewrite $1
Match ^/$ Rewrite /dms
}
Directory {
DirectoryID = static
Path = /usr/share/mayan-edms/mayan/media/static
ExpirePeriod = 2 weeks
}
Directory {
DirectoryID = favicon
Path = /usr/share/mayan-edms/mayan/media/static/appearance/images/
ExpirePeriod = 1 hour
}
VirtualHost {
RequireTLS = yes
Hostname = dms.myhost.localdomain
WebsiteRoot = /srv/http/dms
AccessLogfile = /srv/http/log/dms/access.log
ErrorLogfile = /srv/http/log/dms/error.log
Alias = /static:/usr/share/mayan-edms/mayan/media/static
Alias = /storage:/usr/share/mayan-edms/mayan/media/document_storage
Alias = /cache:/usr/share/mayan-edms/mayan/media/document_cache
ScriptAlias = /dms:/usr/share/mayan-edms/mayan/bin/mayan-edms.py
ExecuteCGI = yes
EnablePathInfo = yes
TimeForCGI = 5
UseFastCGI = MAYAN
NoExtensionAs = py
FollowSymlinks = yes
TLScertFile = ssl/dms.pem
UseToolkit = dms,storage,cache
UseDirectory = static
}


2. While I can use MayanEDMS somehow, I still have to get rid of the "/dms/" path as I can't run it without it.
3. Furthermore, I can't upload documents in Mayan, or better said the documents are actually uploaded and I can see them in the with websites folder "/usr/share/mayan-edms/mayan/media/document_storage" as eg.: "-rw-r----- 1 http http 128885 Sep 10 23:55 shared-file-0700a753c9b149a1ba35d762099e8e62".

After fiddling around for two days with UrlToolkit settings, Alias and ScriptAlias settings it got just worse. Every time I removed the ScriptAlias the whole page wasn't working anymore. Therefore, I thought this Alias-dms-setup is not as it is supposed to be. There must be another way to run the "mayan-edms.py" script each the page is loaded ...

So, I looked up another solution without the need to use "Alias/ScriptAlias" at all. Instead, I found UrlTookit setting "Match .* UseFastCGI" from https://www.hiawatha-webserver.org/forum/topic/505 . With this approach the script is still running without Alias/ScriptAlias settings and it starts without "/dms/" from FQDN. ...

... BUT(!) all CSS formatting is gone and I can't even navigate the page anymore. The initial URL looks fine dms.myhost.localdomain/ but if I click a link (eg. 'Recent Documents' ) it changes to dms.myhost.localdomain/index.html/documents/list/recent/ I don't know where "index.html/" is coming from, because I didn't set any anywhere. Here are my second settings approach:

FastCGIserver {
FastCGIid = MAYAN
ConnectTo = /usr/share/mayan-edms/uwsgi.sock
Extension = py
SessionTimeout = 30
}
UrlToolkit {
ToolkitId = mayan
RequestURI isfile Return
Match ^/(css|files|fonts|images|js)($|/) Return
Match ^/(/index.html) Rewrite $1
Match .* UseFastCGI MAYAN
}
Directory {
DirectoryID = static
Path = /usr/share/mayan-edms/mayan/media/static
ExpirePeriod = 1 hour
}
Directory {
DirectoryID = favicon
Path = /usr/share/mayan-edms/mayan/media/static/appearance/images/
ExpirePeriod = 1 hour
}
VirtualHost {
RequireTLS = yes
Hostname = dms.myhost.localdomain
WebsiteRoot = /usr/share/mayan-edms/mayan/media/static
AccessLogfile = /srv/http/log/dms/access.log
ErrorLogfile = /srv/http/log/dms/error.log
ExecuteCGI = yes
EnablePathInfo = yes
TimeForCGI = 5
NoExtensionAs = py
FollowSymlinks = yes
TLScertFile = ssl/dms.pem
UseToolkit = MAYAN
UseDirectory = static,favicon
}


Now I'm quite discouraged. I tried to mix both setups for countless hours, searched the web and forum for hints and I still think the solution must be somewhere in between. The first one works fine, except for the "dms" and the "Upload issue". The second might be the better way by using the "Match .* UseFastCGI MAYAN" setting, but the site lacks CSS formatting, images and navigation isn't possible anymore.

I hope, someone can maybe take a look at the official deployment page http://mayan.readthedocs.io/en/latest/topics/deploying.html and may have an elegant to all of this.
Thomas
11 September 2016, 21:00
Maybe it is easier to start with converting this nginx config to Hiawatha:

server {
listen 80;
server_name localhost;

location / {
include uwsgi_params;
uwsgi_pass unix:/usr/share/mayan-edms/uwsgi.sock;

client_max_body_size 30M; # Increse if your plan to upload bigger documents
proxy_read_timeout 30s; # Increase if your document uploads take more than 30 seconds
}

location /static {
alias /usr/share/mayan-edms/mayan/media/static;
expires 1h;
}

location /favicon.ico {
alias /usr/share/mayan-edms/mayan/media/static/appearance/images/favicon.ico;
expires 1h;
}
}

This topic has been closed.