Closed jli05 closed 3 months ago
You are right @ac000 . By default the environment variable PATH
for Popen()
is stringent even unitd
is started with --user <my user>
:
/bin:/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
So in the config.json
I added working_directory
parameter.
Then in Python code:
from os import getcwd, environ
from os.path import join
env = {'PATH': join(getcwd(), 'venv', 'bin') + ':' + environ['PATH']}
...
Popen([...], env=env, ...)
Hi,
My Flask app in the
setup.py
has linesso some
.sh
scripts are installed intovenv/bin
directory.Then in the Flask app the scripts would be called by
subprocess
functions asPopen()
etc.Some script would call other scripts in the same
venv/bin
directory, and walk through filesystem somewhere. Overall it is very difficult to obtain expected results. I guess it is that the user isunit
, different than my user.I checked my nginx configuration file. It runs as user
nginx
but can run the Flask app with no problem, passing calls to the WSGI serveruwsgi
.