私は、nginxを使用してuWSGIでPythonフラスコアプリを提供しています。 Pythonコードはブラウザ(Firefox、Chrome)を実行するのにsubprocess.Popen()
を呼び出しますが、uWSGIログにエラーが表示されます。 エラーはlinux(ubuntu)の標準コマンド、すなわちreadlink
,which
、cat
などに関連しています。uWSGI pythonサブプロセスchrome/firefoxが失敗しました
これはユーザーアクセスに関係すると思われますが、わかりません。 ユーザーとwww-data
グループを使用してuWSGIサービスが実行されます。
Pythonのコード
import subprocess
@app.route('/api/check/version', methods=['POST'])
def check_version():
pid = subprocess.Popen(['/usr/bin/firefox', '--version'], stdout=subprocess.PIPE)
#pid = subprocess.Popen(['/usr/bin/google-chrome', '--version'], stdout=subprocess.PIPE)
data = pid.communicate()
return data
if __name__ == "__main__":
check_version()
ログイン
**in case of doing Popen for /usr/bin/firefox
/usr/bin/firefox: 1: /usr/bin/firefox: which: not found
**in case of doing Popen for /usr/bin/google-chrome
/usr/bin/google-chrome-stable: line 8: readlink: command not found
/usr/bin/google-chrome-stable: line 10: dirname: command not found
/usr/bin/google-chrome-stable: line 46: exec: cat: not found
/usr/bin/google-chrome-stable: line 45: exec: cat: not found
uWSGIサービスコンフィグ uWSGI
[Unit]
Description=uWSGI instance to serve myproject
After=network.target
[Service]
User=myuser
Group=www-data
WorkingDirectory=/home/gbadmin/myproject
Environment="PATH=/home/gbadmin/myproject/myprojectenv/bin"
ExecStart=/home/gbadmin/myproject/myprojectenv/bin/uwsgi --ini myproject.ini
[Install]
WantedBy=multi-user.target
迅速な返信をいただきありがとうございます。 – Hussain