Flask应用程序不会一直

2024-04-29 23:16:14 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个问题测试我的烧瓶API应用程序,它不会一直启动。由于需要,我必须确保它在CentOS6上运行(默认情况下是Python2.6),但我使用的是定制的Python2.7VirtualEnv。我的启动命令如下:

/opt/mist/mist_base/env/bin/uwsgi --py-autoreload 1 --master --socket=/tmp/mist_app.sock --pidfile=/tmp/mist_app.pid --module=wsgi --honour-stdin --chdir=/opt/mist/mist_base/app --threads=1 --virtualenv=/opt/mist/mist_base/env --die-on-term --uid mist --gid mist

其中自定义virtualenv是/opt/mist/mist_base/env。你知道吗

我让人帮我把这个软件打包成可以用RPM/Yum安装的(他以前做过,这样打包是必须的);在这个过程中,他坚持要构建另一个定制的python virtualenv(/opt/mist/mist_base/.localpython)。不幸的是,他已经离开了公司,我们不知道他做了什么。我在另一个virtualenv中查找了可以调用二进制文件/库的RPM build/init命令,但没有找到任何命令。你知道吗

使用提供给我的指令,我构建了生成的RPM,并将其安装在测试服务器上,一切运行正常。我给了我的客户相同的转速安装在他的测试服务器,它不会启动。你知道吗

我的工作引导顺序如下:

*** Starting uWSGI 2.0.14 (64bit) on [Thu May 18 13:49:09 2017] ***
compiled with version: 4.4.7 20120313 (Red Hat 4.4.7-17) on 20 March 2017 07:18:55
os: Linux-2.6.32-696.1.1.el6.x86_64 #1 SMP Tue Apr 11 17:13:24 UTC 2017
nodename: mistdb
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
current working directory: /opt/mist/mist_base/app
writing pidfile to /tmp/mist_app.pid
detected binary path: /opt/mist/mist_base/env/bin/uwsgi
setgid() to 487
setuid() to 493
chdir() to /opt/mist/mist_base/app
your processes number limit is 7394
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /tmp/mist_app.sock fd 3
Python version: 2.7.5 (default, Mar 20 2017, 06:43:30)  [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]
Set PythonHome to /opt/mist/mist_base/env
Python main interpreter initialized at 0x21c4aa0
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 145536 bytes (142 KB) for 1 cores
*** Operational MODE: single process ***
WSGI app 0 (mountpoint='') ready in 2 seconds on interpreter 0x21c4aa0 pid: 24902 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 24902)
spawned uWSGI worker 1 (pid: 24907, cores: 1)
Python auto-reloader enabled

同时,我的客户看到:

*** Starting uWSGI 2.0.14 (64bit) on [Tue May 16 13:12:26 2017] ***
compiled with version: 4.4.7 20120313 (Red Hat 4.4.7-17) on 20 March 2017 07:18:55
os: Linux-2.6.32-696.1.1.el6.x86_64 #1 SMP Tue Mar 21 12:19:18 EDT 2017
nodename: mist-testbed
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 2
current working directory: /
writing pidfile to /tmp/mist_app.pid
detected binary path: /opt/mist/mist_base/env/bin/uwsgi
setgid() to 497
setuid() to 497
chdir() to /opt/mist/mist_base/app
your processes number limit is 15208
your memory page size is 4096 bytes
detected max file descriptor number: 1024
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to UNIX address /tmp/mist_app.sock fd 3
Python version: 2.7.5 (default, Mar 20 2017, 06:43:30)  [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]
Set PythonHome to /opt/mist/mist_base/env
Python main interpreter initialized at 0x280c890
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 145536 bytes (142 KB) for 1 cores
*** Operational MODE: single process ***
ERROR:root:code for hash md5 was not found.
Traceback (most recent call last):
  File "/opt/mist/mist_base/.localpython/lib/python2.7/hashlib.py", line 139, in <module>
    globals()[__func_name] = __get_hash(__func_name)
  File "/opt/mist/mist_base/.localpython/lib/python2.7/hashlib.py", line 103, in __get_openssl_constructor
    return __get_builtin_constructor(name)
  File "/opt/mist/mist_base/.localpython/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type md5
Traceback (most recent call last):
  File "./wsgi.py", line 1, in <module>
    from mist_main import app as application
  File "./mist_main.py", line 1, in <module>
    from _app import return_app
  File "./_app.py", line 1, in <module>
    from flask import Flask, Blueprint, render_template, session, redirect, url_for, escape, request, abort
  File "/opt/mist/mist_base/env/lib/python2.7/site-packages/flask/__init__.py", line 17, in <module>
    from werkzeug.exceptions import abort
  File "/opt/mist/mist_base/env/lib/python2.7/site-packages/werkzeug/__init__.py", line 151, in <module>
    __import__('werkzeug.exceptions')
  File "/opt/mist/mist_base/env/lib/python2.7/site-packages/werkzeug/exceptions.py", line 71, in <module>
    from werkzeug.wrappers import Response
  File "/opt/mist/mist_base/env/lib/python2.7/site-packages/werkzeug/wrappers.py", line 26, in <module>
    from werkzeug.http import HTTP_STATUS_CODES, \
  File "/opt/mist/mist_base/env/lib/python2.7/site-packages/werkzeug/http.py", line 32, in <module>
    from hashlib import md5
ImportError: cannot import name md5
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 25071)
spawned uWSGI worker 1 (pid: 25072, cores: 1)
Python auto-reloader enabled

在启动期间,应用程序首先尝试使用.localpython virtualenv,然后尝试使用env virtualenv。因为我找不到任何使用.localpython的RPM/init代码,所以我无法解释为什么是1。我的应用实例不使用它2。我客户的实例是这样的。你知道吗

这完全有可能是由于环境的不同,我们将尝试根据它们的规格构建一个虚拟机,看看这是否解决了这个问题。这也可能仅仅是一个损坏的virtualenv和/或没有包含所有需要的外部库的情况吗?你知道吗


Tags: toinpyimportenvappbaseis
1条回答
网友
1楼 · 发布于 2024-04-29 23:16:14

我的客户今天回来了,看起来他们在CentOS 6服务器上做了一些我们没有做的事情。具体来说,他们运行一个脚本来启用服务器的FIPS,这与我的定制python2.7环境如何与内置的加密库交互有关。你知道吗

相关问题 更多 >