为服务文件调用的 uwsgi 应用程序设置 oracle 路径
Set oracle path for uwsgi app called by service file
我已经用 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
然而,由于服务文件不使用它来加载它的环境变量,所以它似乎找不到它
错误日志
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
像这样的问题是 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.
我已经用 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
然而,由于服务文件不使用它来加载它的环境变量,所以它似乎找不到它
错误日志
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
像这样的问题是 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.