首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在WSGI上运行Pyvirtualdisplay

在WSGI上运行Pyvirtualdisplay
EN

Stack Overflow用户
提问于 2018-08-29 23:49:22
回答 1查看 79关注 0票数 0

我正在尝试将pyvirtualdisplay作为WSGI应用程序的一部分来运行。我已经安装了Xfvb,我的000-default.conf文件:

代码语言:javascript
复制
<VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName www.example.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    WSGIDaemonProcess flaskapp user=ubuntu threads=5
    WSGIScriptAlias / /var/www/html/flaskapp/flaskapp.wsgi
    <Directory flaskapp>
        WSGIProcessGroup flaskapp
        WSGIApplicationGroup %{GLOBAL}
        Require all granted
    </Directory>
    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

我的代码:

代码语言:javascript
复制
from flask import Flask
from pyvirtualdisplay import Display

app = Flask(__name__)

@app.route('/')
def crawl_sc():
    display = Display(visible=0, size=(1920, 999))
    display.start()
    display.stop()
    return 'ran'
if __name__ == '__main__':
    app.run(debug=True)

当我通过WSGI运行它时,它只是不断地加载,但在error.log中没有错误。我使用的是带有Ubuntu16.04和Apache2.4.18、mod_wsgi 4.6.4和Python3.6的亚马逊EC2。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-08-31 23:05:52

因此,在联系了mod_wsgi的git代码库的所有者后,我发现我一直在嵌入式模式下使用上面的000-default.conf来运行它。在embedded中,它不使用主解释器。为了解决这个问题,我将上面的代码改为:

代码语言:javascript
复制
 <Directory /var/www/html/flaskapp>
    WSGIProcessGroup flaskapp
    WSGIApplicationGroup %{GLOBAL}
    Require all granted
 </Directory>

这使用了主解释器,现在脚本运行:)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52081522

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档