Search code examples
uwsgi

uWSGI with --master causing Illegal Seek errors


uWSGI is causing Illegal Seek errors. I finally narrowed it down to the --master flag. If I have the master process enabled, then after starting uWSGI I get tons of these, about 1 per second:

uwsgi_check_logrotate()/lseek(): Illegal seek [core/logging.c line 497]

I've been pouring over the uWSGI docs but cannot find anything on how to correctly set up the master or what it needs to function properly.

Any help would be appreciated, as I've read the master process is quite crucial for a production environment.

I'm uncertain why turning on the --master process would cause this to happen, but I finally stumbled on a possible cause:

The most basic form of logging in uWSGI is writing requests, errors, and >informational messages to stdout/stderr. This happens in the default >configuration. The most basic form of log redirection is the --logto / --logto2 / >--daemonize options which allow you to redirect logs to files.

I had had logto = path/to/logfile declared and didn't realize that the default behavior was to send logs to stdout. So I'd made a system link to stdout from my log file.

However this doesn't seem to be a problem when the --master process is not turned on.


Solution

  • I solved this problem by delegating the logging to the master process with the flag:

    --log-master

    from https://github.com/unbit/uwsgi/blob/d960f8fdc36b33c60b7291ca8e32dbb5df22cf15/core/uwsgi.c#L794

    {"log-master", no_argument, 0, "delegate logging to master process", uwsgi_opt_true, &uwsgi.log_master, UWSGI_OPT_MASTER|UWSGI_OPT_LOG_MASTER},