1

Topic: iRedAdmin : ImportError: No module named settings

============ Required information ====
- iRedMail version (check /etc/iredmail-release): 0.9.4
- Linux/BSD distribution name and version: Debian 8.3
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): Mysql
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro? No (postfixadmin)
- Related log if you're reporting an issue: See in post
====

I Switched from apache to Nginx (much simpler config in my eyes, apache is a mess), everything works as intended exept iRedAdmin,
So I added UWSGI (and depandancy), copy the configuration files.

 cat /etc/uwsgi/apps-enabled/iredadmin.ini
[uwsgi]
plugins=python
vhost=true
socket=/var/run/uwsgi/app/iredadmin/iredadmin.socket

it starts, with no error in log, then here is the configuration of Nginx

    # iRedAdmin: static files under /iredadmin/static
    location ~ ^/iredadmin/static/(.*)\.(png|jpg|gif|css|js) {
        alias /usr/share/apache2/iredadmin/static/$1.$2;
    }

    # iRedAdmin: Python scripts
    location ~ ^/iredadmin(.*) {
        rewrite ^/iredadmin(/.*)$ $1 break;
        include uwsgi_params;
        uwsgi_pass unix:/var/run/uwsgi/app/iredadmin/iredadmin.socket;
        uwsgi_param UWSGI_CHDIR /usr/share/apache2/iredadmin;
        uwsgi_param UWSGI_SCRIPT iredadmin;
        uwsgi_param SCRIPT_NAME /iredadmin;
    }
    # iRedAdmin: redirect /iredadmin to /iredadmin/
    location = /iredadmin {
        rewrite ^ /iredadmin/;
    }

Socket exist, path are valid, I'm able to load it in the browser, but I have : "Internal Server Error" that show up.
And i Have in /var/log/uwsgi/app/iredadmin.log

Traceback (most recent call last):
  File "/usr/share/apache2/iRedAdmin-0.5/iredadmin.py", line 9, in <module>
    from libs import iredbase
  File "/usr/share/apache2/iRedAdmin-0.5/libs/iredbase.py", line 18, in <module>
    import iredutils
  File "/usr/share/apache2/iRedAdmin-0.5/libs/iredutils.py", line 14, in <module>
    import settings
ImportError: No module named settings
Tue Mar  8 14:33:37 2016 - unable to load app 0 (mountpoint='mail.DOMAIN.com|/iredadmin') (callable not found or import error)
Tue Mar  8 14:33:37 2016 - --- no python application found, check your startup logs for errors ---
mail.DOMAIN.com [pid: 4078|app: -1|req: -1/3] 192.168.10.104 () {50 vars in 899 bytes} [Tue Mar  8 14:33:37 2016] GET /iredadmin/ => generated 21 bytes in 4 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)

I Checked in the /usr/share/apache2/iredadmin/ folder, here is the content : 

 ls -lah /usr/share/apache2/iredadmin/
total 100K
dr-xr-xr-x  9 iredadmin iredadmin 4.0K Mar  8 14:32 .
drwxr-xr-x 20 root      root      4.0K Mar  8 14:31 ..
-r-xr-xr-x  1 iredadmin iredadmin   49 Mar  8 14:31 AUTHORS
-r-xr-xr-x  1 iredadmin iredadmin 7.3K Mar  8 14:31 ChangeLog
-r-xr-xr-x  1 iredadmin iredadmin  18K Mar  8 14:31 LICENSE
-r-xr-xr-x  1 iredadmin iredadmin  439 Mar  8 14:31 README
dr-xr-xr-x  6 iredadmin iredadmin 4.0K Jan 27 17:54 controllers
dr-xr-xr-x  3 iredadmin iredadmin 4.0K Jan 27 17:54 docs
dr-xr-xr-x 18 iredadmin iredadmin 4.0K Jan 27 17:54 i18n
-r-xr-xr-x  1 iredadmin iredadmin  402 Mar  8 14:31 iredadmin.py
dr-xr-xr-x  6 iredadmin iredadmin 4.0K Mar  8 14:31 libs
-r--------  1 iredadmin iredadmin 4.2K Mar  8 14:31 settings.py
-r-xr-xr-x  1 iredadmin iredadmin 4.1K Mar  8 14:31 settings.py.ldap.sample
-r-xr-xr-x  1 iredadmin iredadmin 3.5K Mar  8 14:31 settings.py.mysql.sample
-r-xr-xr-x  1 iredadmin iredadmin 3.5K Mar  8 14:31 settings.py.pgsql.sample
dr-xr-xr-x  4 iredadmin iredadmin 4.0K Jan 27 17:54 static
dr-xr-xr-x  3 iredadmin iredadmin 4.0K Jan 27 17:54 templates
dr-xr-xr-x  2 iredadmin iredadmin 4.0K Mar  8 14:31 tools

iRedAdmin version is 0.5, I tried to rerun the tools/upgrade_iredadmin.sh witch worked without any error.
I cant figure out why, settings.py cant be loaded.

Any hint ?

PS:settings.py do contains correct settings for my installation.
PSPS: Thanks, again, for iredmail, it's quite nice.

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: iRedAdmin : ImportError: No module named settings

Add new settings in your /etc/uwsgi/apps-enabled/iredadmin.ini, then restart uwsgi service and try again:

uid = iredadmin
gid = iredadmin

3

Re: iRedAdmin : ImportError: No module named settings

nano /etc/uwsgi/apps-available/iredadmin.ini
root@mail:~# service uwsgi restart
[ ok ] Restarting app server(s): uwsgi -> . done.
root@mail:~# service nginx restart
[ ok ] Restarting nginx: nginx.
502 Bad Gateway
nginx/1.6.2

No error in /var/log/uwsgi/app/iredadmin.log
Here is the output :

Wed Mar  9 09:42:13 2016 - Python main interpreter initialized at 0x994aaf0
Wed Mar  9 09:42:13 2016 - your server socket listen backlog is limited to 100 connections
Wed Mar  9 09:42:13 2016 - your mercy for graceful operations on workers is 60 seconds
Wed Mar  9 09:42:13 2016 - mapped 191964 bytes (187 KB) for 2 cores
Wed Mar  9 09:42:13 2016 - *** Operational MODE: preforking ***
Wed Mar  9 09:42:13 2016 - *** no app loaded. going in full dynamic mode ***
Wed Mar  9 09:42:13 2016 - *** uWSGI is running in multiple interpreter mode ***
Wed Mar  9 09:42:13 2016 - spawned uWSGI master process (pid: 27285)
Wed Mar  9 09:42:13 2016 - spawned uWSGI worker 1 (pid: 27302, cores: 1)
Wed Mar  9 09:42:13 2016 - spawned uWSGI worker 2 (pid: 27303, cores: 1)
^C

I fell like the "no app loaded" is the main problem

4

Re: iRedAdmin : ImportError: No module named settings

This is the full content of /etc/uwsgi/apps-enabled/iredadmin.ini with default iRedMail setting, please try again:

[uwsgi]
plugins = python
vhost = true
socket = /var/run/uwsgi_iredadmin.socket
#pidfile = /var/run/uwsgi_iredadmin.pid
chown-socket = www-data:www-data
chmod-socket = 660
uid = iredadmin
gid = iredadmin
enable-threads = true

5

Re: iRedAdmin : ImportError: No module named settings

I added the full content off the provided file, restarted uwsgi, changed the nginx conf to

uwsgi_pass unix:/var/run/uwsgi_iredadmin.socket;

instead of

uwsgi_pass unix:/var/run/uwsgi/app/iredadmin/iredadmin.socket;

And it's fixed

Thanks ZhangHuangbin