pythonnginxflaskuwsgilogfiles

Error when creating log file in uwsgi ini file using date


I am trying to deploy my Flask app on Nginx using uWSGI. I used this tutorial to deploy my flask app. I have the following ini file: extractor.ini

    [uwsgi]
    module = wsgi:app

    master = true 
    processes = 5

    socket = extractor.sock
    chmod-socket = 660

    vacuum = true

    log-date = @(exec://date +%%F-%%H-%%M)
    logdir = /home/rkok/extractor/logs/
    daemonize = %(logdir)uwsgi-%(log-date).log

    die-on-term = true

However when I try to start my project using

sudo systemctl start extractor

it shows the following error when I check the service status:

uwsgi[31788]: /bin/sh: 1: date: not found

I have read here that all 2.x versions should support @(exec://date +%%F-%%H-%%M). %%F-%%H-%%M should become YYYY-mm-dd-HH-MM format in the ini file.

I the reactions it says that it could be my path, but I am unsure about how to check my path inside an ini file, as I am using a virtualenv instead of my system environment. My system setting:

Ubuntu 16.04 LTS x64
Python 3.5.2
Virtualenv 15.1.0
uWSGI 2.0.15
Nginx 1.10.3

So my question is: How can I get uWSGI to generate a new log file using the system datetime inside the ini file?

ps. My flask app deploys succesfully when I leave out the @(exec://date +%%F-%%H-%%M) part.


Solution

  • The issue could be because of PATH environment variable being different in the two environments. So you should be using absolute paths instead. Change

    log-date = @(exec://date +%%F-%%H-%%M)
    

    to

    log-date = @(exec:///bin/date +%%F-%%H-%%M)