简体   繁体   English

使用日期在uwsgi ini文件中创建日志文件时出错

[英]Error when creating log file in uwsgi ini file using date

I am trying to deploy my Flask app on Nginx using uWSGI. 我正在尝试使用uWSGI将我的Flask应用程序部署在Nginx上。 I used this tutorial to deploy my flask app. 我使用了教程来部署我的flask应用程序。 I have the following ini file: extractor.ini 我有以下ini文件: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). 我在这里阅读到所有2.x版本都应支持@(exec:// date + %% F-%% H-%% M)。 %%F-%%H-%%M should become YYYY-mm-dd-HH-MM format in the ini file. %% F-%% H-%% M应该在ini文件中成为YYYY-mm-dd-HH-MM格式。

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. 我的反应是它可能是我的路径,但是我不确定如何检查ini文件中的路径,因为我使用的是virtualenv而不是系统环境。 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? 所以我的问题是:如何让uWSGI使用ini文件中的系统日期时间来生成新的日志文件?

ps. PS。 My flask app deploys succesfully when I leave out the @(exec://date +%%F-%%H-%%M) part. 当我忽略@(exec:// date + %% F-%% H-%% M)部分时,flask应用程序成功部署。

The issue could be because of PATH environment variable being different in the two environments. 问题可能是由于PATH环境变量在两个环境中不同。 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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM