1 (edited by Chrissicom 2015-05-26 01:36:29)

Topic: iRedAdmin w/ nginx not working, uwsgi config issue (includes solution)

======== Required information ====
- iRedMail version: 0.9.1
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MySQL
- Web server (Apache or Nginx): Nginx
- Linux/BSD distribution name and version: CentOS 6.6
====

Hello. I have setup iRedMail on a clean server install. On my first try I got a warning during the installation.

cp: cannot create regular file `/etc/uwsgi/iredadmin.ini': No such file or directory

The service uwsgi was not able to start and without further research I have restored a backup of the server. The webmail client worked, but I also want iRedAdmin.

I then created the directory /etc/uwsgi/ manually. iRedMail setup then went through without the warning and the iredadmin.ini was also copied in its location during setup.

But still I cannot run uwsgi (I have rebooted the server). When I try to I get a long error message. At some point it says something about permission denied, but I don't understand what permission where is denied, since there is nothing irregular to be found in the system logs.

# service uwsgi start
Starting uwsgi Fast, self-healing, application container server: [uWSGI] getting INI configuration from /etc/uwsgi.ini
setting capability setgid [6]
setting capability setuid [7]
*** Starting uWSGI 2.0.9 (32bit) on [Mon May 25 19:06:10 2015] ***
compiled with version: 4.4.7 20120313 (Red Hat 4.4.7-11) on 23 April 2015 19:31:06
os: Linux-2.6.32-042stab103.6 #1 SMP Wed Jan 21 13:07:39 MSK 2015
nodename: <<<removed>>>
machine: i686
clock source: unix
pcre jit disabled
detected number of CPU cores: 2
current working directory: /
writing pidfile to /run/uwsgi/uwsgi.pid
detected binary path: /usr/sbin/uwsgi
setgid() to 494
setuid() to 494
your processes number limit is 2062030
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)
your mercy for graceful operations on workers is 60 seconds
*** Operational MODE: no-workers ***
spawned uWSGI master process (pid: 2904)
bind(): Permission denied [core/socket.c line 230]
waiting for Emperor death...
The Emperor has been buried (pid: 2905)
...brutally killing workers...
                                                           [FEHLGESCHLAGEN]

I have also noticed that the socket and pid file specified in /etc/uwsgi/iredmail.ini does not exist. Well, obvious since it doesn't run properly, but in the error message I can see a default .ini file is loaded. So I have tried to replace this file with the iredmail.ini file. I have actually created a symlink.

ln -s /etc/uwsgi.ini /etc/uwsgi/iredadmin.ini

Now uwsgi starts, however it switches to some dynamic mode and it seems it is running on the console and only as long as the console stays open. iRedAdmin works now however.

# service uwsgi start
Starting uwsgi Fast, self-healing, application container server: [uWSGI] getting INI configuration from /etc/uwsgi.ini
*** Starting uWSGI 2.0.9 (32bit) on [Mon May 25 19:12:36 2015] ***
compiled with version: 4.4.7 20120313 (Red Hat 4.4.7-11) on 23 April 2015 19:31:06
os: Linux-2.6.32-042stab103.6 #1 SMP Wed Jan 21 13:07:39 MSK 2015
nodename: <<<removed>>>
machine: i686
clock source: unix
pcre jit disabled
detected number of CPU cores: 2
current working directory: /
writing pidfile to /var/run/uwsgi_iredadmin.pid
detected binary path: /usr/sbin/uwsgi
*** WARNING: you are running uWSGI without its master process manager ***
your processes number limit is 2062030
your memory page size is 4096 bytes
detected max file descriptor number: 1024
VirtualHosting mode enabled.
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /var/run/uwsgi_iredadmin.socket fd 3
setgid() to 2001
setuid() to 2001
Python version: 2.6.6 (r266:84292, Jan 22 2014, 09:37:14)  [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)]
Python main interpreter initialized at 0x8af2128
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 63988 bytes (62 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 worker 1 (and the only) (pid: 3008, cores: 1)
WSGI app 0 (mountpoint='<<<removed>>>|/iredadmin') ready in 0 seconds on interpreter 0x8af2128 pid: 3008
<<<removed>>> [pid: 3008|app: 0|req: 1/1] 62.157.68.96 () {50 vars in 790 bytes} [Mon May 25 19:12:53 2015] GET /iredadmin/ => generated 4821 bytes in 743 msecs (HTTP/1.1 200) 1 headers in 111 bytes (3 switches on core 0)

So the only question that remains is, how do I get to run uwsgi to run as a regular service now?

Edit: After a second reboot uwsgi started as a service with the symlinked config smile. Yeah! So consider this a problem report AND solution.

----

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

2

Re: iRedAdmin w/ nginx not working, uwsgi config issue (includes solution)

This is an unexpected issue: uwsgi was not available in EPEL before, so we build our own RPM packages, but someone submitted uwsgi to EPEL with higher priority and incompatible with iRedMail's package, so this issue happened.

It was fixed in the latest development release of iRedMail and will be available in iRedMail-0.9.2 very soon.

3

Re: iRedAdmin w/ nginx not working, uwsgi config issue (includes solution)

Same problem here, Zhang...

Do you have a workaround?

4 (edited by Chrissicom 2015-05-28 03:23:57)

Re: iRedAdmin w/ nginx not working, uwsgi config issue (includes solution)

Hi annonman, I think my posting is the "workaround" until 0.9.2 is released.
If you follow the steps I described iRedMail works without any issues.

5 (edited by annonman 2015-05-28 06:26:38)

Re: iRedAdmin w/ nginx not working, uwsgi config issue (includes solution)

On my Centos 6.6 system the hack does work on reboot, however fail2ban and iradapd fail to start.

(They can be started manually however).

Thanks.

6

Re: iRedAdmin w/ nginx not working, uwsgi config issue (includes solution)

annonman wrote:

On my Centos 6.6 system the hack does work on reboot, however fail2ban and iradapd fail to start.

(They can be started manually however).

Thanks.

I can confirm this. Although iredapd and fail2ban are set to start automatically they do not. Starting them manually works and there seem to be no errors. However after a reboot (which is not always monitored) the services do not start. I do not know exactly what iredapd does, but fail2ban not starting is definitely a problem.

7

Re: iRedAdmin w/ nginx not working, uwsgi config issue (includes solution)

iRedAPD not starting is a bigger problem Chrissicom, it means that all mail will be stuck in queue as it is the Policy Daemon

8

Re: iRedAdmin w/ nginx not working, uwsgi config issue (includes solution)

Big problem indeed ;-)

I have added two lines to /etc/rc.d/rc.local

/etc/rc.d/init.d/iredapd start
/etc/rc.d/init.d/fail2ban start

But that doesn't work. The services still don't start on reboot.

I don't understand what the problem is, since starting the services manually works without any issues.

9

Re: iRedAdmin w/ nginx not working, uwsgi config issue (includes solution)

Is there anything in syslog or the application's own logs after a reboot?

10

Re: iRedAdmin w/ nginx not working, uwsgi config issue (includes solution)

I have checked the fail2ban and iredapd logs. All logged information is just informational. There are not even warnings (and no errors). The syslog shows no errors or warnings either (/var/log/messages and lastlog).

11

Re: iRedAdmin w/ nginx not working, uwsgi config issue (includes solution)

I turned off uwsgi:

chkconfig uwsgi off

then rebooted.

If I need iRedAdmin, i can turn it on manually.

Fail2ban and iRedAPD are Python applications.  This is why they won't start at boot with the new (non-iRedMail) uwsgi package.

12

Re: iRedAdmin w/ nginx not working, uwsgi config issue (includes solution)

iRedAPD and Fail2ban is Python application, but they don't use uwsgi at all, 2 separate issues.

If you run 'chkconfig --level 345 iredapd on', iredapd should auto-start after system reboot. No idea why it doesn't work.

13 (edited by Chrissicom 2015-05-31 04:00:45)

Re: iRedAdmin w/ nginx not working, uwsgi config issue (includes solution)

Updated information:
Basically on CentOS 7 the uwsgi installation error also occurs and can be solved the same way as described above for CentOS 6.6.

However on CentOS 7 fail2ban and iredapd start without any issues automatically. So as long as yo don't need SOGo CentOS 7 is the better solution at the moment.

14 (edited by Blocker 2015-06-02 21:15:30)

Re: iRedAdmin w/ nginx not working, uwsgi config issue (includes solution)

I too have this problem after doing an upgrade. iredapd is running fine but uwsgi fails to start even after reboot.

Ohh btw, I tried to add the sym link hack described above and got an error message that the file exists..
My system CentOS 6.6

15

Re: iRedAdmin w/ nginx not working, uwsgi config issue (includes solution)

mv /etc/uwsgi.ini /etc/uwsgi.ini.original

... before creating the symlink. The symlink actually is no necessity as you could just copy the contents and overwrite the original files contents. I do however prefer to keep original config files in their actual locations and symlinks is an elegant way to make apps think the file is in another place.

16 (edited by Blocker 2015-06-02 21:46:12)

Re: iRedAdmin w/ nginx not working, uwsgi config issue (includes solution)

hmm, ok.. renaming the file and trying to create the sym link still didn't work, so I copied and renamed the iredadmin.ini file to uwsgi.ini in /etc and it works but only when in console. Trying to run as a service still fails.. It least can start it manually when needing to do any admin work.

Thanks for the help..

17

Re: iRedAdmin w/ nginx not working, uwsgi config issue (includes solution)

Read what I wrote above. It fails when running it manually, but when you reboot your server the service should start just fine.

18 (edited by Blocker 2015-06-02 22:04:43)

Re: iRedAdmin w/ nginx not working, uwsgi config issue (includes solution)

Chrissicom wrote:

Read what I wrote above. It fails when running it manually, but when you reboot your server the service should start just fine.

I think you misunderstood what I was trying to say.. The service does not start after a reboot on my system
root@# service uwsgi status
uwsgi is stopped
root@# service uwsgi start
root@#
root@# service uwsgi status
uwsgi (pid 1748) is running...

I have tried this after multiple reboots.. and yes it should start at reboot ie:
root@# chkconfig --list | grep 3:on
uwsgi              0:off    1:off    2:off    3:on    4:on    5:on    6:off

19

Re: iRedAdmin w/ nginx not working, uwsgi config issue (includes solution)

Can you post the contents of your /etc/uwsgi.ini file please.

20

Re: iRedAdmin w/ nginx not working, uwsgi config issue (includes solution)

Chrissicom wrote:

Can you post the contents of your /etc/uwsgi.ini file please.

Sure, here tis..

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

21

Re: iRedAdmin w/ nginx not working, uwsgi config issue (includes solution)

Dear all,

This fix is mentioned in upgrade tutorial for upcoming iRedMail-0.9.2 release, check it here:
http://www.iredmail.org/docs/upgrade.ir … gi-package

Note: this upgrade tutorial is still a draft, do not apply all of them. Just apply this uwsgi fix.

22

Re: iRedAdmin w/ nginx not working, uwsgi config issue (includes solution)

I can confirm on Centos 6.6 uwsgi, fail2ban and iredapd all start successfully after 0.9.2 fixes.

23

Re: iRedAdmin w/ nginx not working, uwsgi config issue (includes solution)

I have executed the tutorial to upgrade to 0.9.2 on a clean 0.9.1 install and although the uwsgi service is running, I get a "502 Bad Gateway" error when opening iRedAdmin.

The uwsgi log is empty, the nginx log shows the following error (I have removed personal information).

[error] 720#0: *1 upstream prematurely closed connection while reading response header from upstream, client: x.x.x.x, server: example.org, request: "GET /iredadmin HTTP/1.1", upstream: "uwsgi://unix:/var/run/uwsgi_iredadmin.socket:", host: "example.org"

24

Re: iRedAdmin w/ nginx not working, uwsgi config issue (includes solution)

For some reason the package uwsgi-plugin-python was gone, although it was there before. Maybe when trying to fix the errors I have accidently removed it. Everything works fine now with the fixes described in 0.9.1 -> 0.9.2 tutorial.

However I would like to recommend to change the uwsgi.ini file to the following since the daemonize option is not necessary on current CentOS since this is done by the systemctl service already.

[uwsgi]

logto = /var/log/uwsgi.log

# try to autoload appropriate plugin if "unknown" option has been specified
autoload = true

# enable master process manager
master = true

# spawn 2 uWSGI worker processes
workers = 2

# automatically kill workers on master's death
no-orphans = true

# place timestamps into log
log-date = true

# user identifier of uWSGI processes
#uid = uwsgi

# group identifier of uWSGI processes
#gid = uwsgi

# multi-app deployment
emperor = /etc/uwsgi.d
emperor-tyrant = false

I have also removed the socket config from the default uwsgi.ini file, since I have no other sites running that would require it and iRedAdmin has its own uwsgi socket.

25

Re: iRedAdmin w/ nginx not working, uwsgi config issue (includes solution)

'daemonize' option is used for CentOS 6.