> I actually found that flock has, for some reason, no effect whatsoever > when daemonize is used. (Is that fd inadvertently closed?) > > This is on an ext4 filesystem. The related test configs: (the asdf > lockfile was pre-created) > > $ cat x.ini > [uwsgi] > flock=asdf > socket=/tmp/test.sock > daemonize=foo.log > > $ cat x-nodaemon.ini > [uwsgi] > flock=asdf > socket=/tmp/test.sock > > First session, showing two daemonized uWSGIs and one non-daemonized uWSGI > starting concurrently with the same flock file: > > $ uwsgi-1.4.3 x.ini > [uWSGI] getting INI configuration from x.ini > > $ uwsgi-1.4.3 x.ini > [uWSGI] getting INI configuration from x.ini > > $ ps aux | grep x.ini > 21943 ... uwsgi-1.4.3 x.ini > 21947 ... uwsgi-1.4.3 x.ini > > $ uwsgi-1.4.3 x-nodaemon.ini > [uWSGI] getting INI configuration from x-nodaemon.ini > *** Starting uWSGI 1.4.3 (64bit) on [Tue Jan 15 09:50:39 2013] *** > > And a second session, with two non-daemonized uWSGIs with the same > lockfile: > > (shell 1) $ uwsgi-1.4.3 x-nodaemon.ini > [uWSGI] getting INI configuration from x-nodaemon.ini > *** Starting uWSGI 1.4.3 (64bit) on [Tue Jan 15 09:51:23 2013] *** > > (shell 2) $ uwsgi-1.4.3 x-nodaemon.ini > [uWSGI] getting INI configuration from x-nodaemon.ini > uWSGI ERROR: asdf is locked by another instance > (shell 2) $ > > Strange... > > -
it is the expected behaviour. If you fork() after a flock(), the lock is lost. You have to use flock2 to postpone flock() after daemonization -- Roberto De Ioris http://unbit.it _______________________________________________ uWSGI mailing list [email protected] http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
