我有一个测试我的烧瓶API应用程序的问题,它不会一直启动。由于要求,我必须确保它在CentOS6上运行(默认情况下为python 2.6),但我使用自定义python 2.7 virtualenv。我的启动命令如下:
/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
)。不幸的是,他已离开公司,我们没有详细说明做了什么。我查找了RPM build / init命令,这些命令会在其他virtualenv中调用二进制文件/库,但我没有找到。
使用提供给我的说明,我构建了生成的RPM并将其安装在我的测试服务器上,一切运行正常。我向我的客户提供了相同的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.我的app实例不使用它2.我的客户的实例确实如此。
完全有可能是由于环境的差异,我们将尝试根据他们的规范构建VM,看看是否能解决这个问题。这也可能只是一个破坏了virtualenv和/或没有包含所有必需的外部库的情况吗?
答案 0 :(得分:0)
我的客户今天回来了,看起来他们为我们不做的CentOS 6服务器做了一些额外的事情。具体来说,他们运行一个脚本来FIPS启用他们的服务器,并以某种方式搞砸我的自定义python 2.7环境如何与内置加密库交互。