我已经用uwsgi和nginx部署了flask应用程序
以下是uwsgi的.ini文件
[uwsgi]
;module = name of file which contains the application object in this case wsgi.py
LD_LIBRARY_PATH=/usr/lib/oracle/18.3/client64/lib
chdir=/home/ansible/apps/payment_handler
module = wsgi:application
;tell uWSGI (the service) to start in master mode and spawn 5 worker *processes* to serve requests
master = true
processes = 5
;a socket is much faster than a port, and since we will be using nginx to exppose the application this is better
socket = 0.0.0.0:8001
vaccum = true
die-on-term = true
当我从命令行这样运行时
uwsgi --ini payment_app.ini
有效!
但是我想使用服务来运行应用程序,以下是服务文件
[Unit]
Description=uWSGI instance to serve service app
After=network.target
[Service]
User=root
WorkingDirectory=/home/ansible/apps/payment_handler
Environment="PATH=/home/ansible/apps/payment_handler/env/bin"
ExecStart=/home/ansible/apps/payment_handler/env/bin/uwsgi --ini payment_app.ini
[Install]
WantedBy=multi-user.target
但是它不起作用,因为它找不到cx_oracle的库 我已经在我的bashrc文件中设置了它
export LD_LIBRARY_PATH=/usr/lib/oracle/18.3/client64/lib
但是,由于服务文件不使用它来加载它的env变量,因此似乎找不到它
错误日志
Jun 17 09:58:06 mau-app-036 uwsgi: cx_Oracle.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "libclntsh.so: cannot open shared object file: No such file or directory". See https://oracle.github.io/odpi/doc/installation.html#linux for help
我尝试将其设置为.ini文件(如上所示)
LD_LIBRARY_PATH=/usr/lib/oracle/18.3/client64/lib
我还尝试过使用os模块在 init .py文件中进行设置
os.environ['LD_LIBRARY_PATH'] = '/usr/lib/oracle/18.3/client64/lib'
无论如何都无济于事,感谢Centos 7 btw
答案 0 :(得分:1)
像这样的问题是Instant Client installation instructions建议运行的原因:
sudo sh -c "echo /usr/lib/oracle/18.3/client64/lib > \
/etc/ld.so.conf.d/oracle-instantclient.conf"
sudo ldconfig
这省去了确定LD_LIBRARY_PATH的方式和位置的麻烦。
请注意,19.3 Instant Client RPM软件包会自动为您运行。 Instant Client 19c Linux x64 release announcement blog中有一些背景。