Getting FileNotFoundError: [Errno 2] No such file or directory: 'bash'
error while running my gunicorn python app form .service file.
However running gunicorn command by itself(not from .service file) works fine.
gunicorn command to run the app
gunicorn -k geventwebsocket.gunicorn.workers.GeventWebSocketWorker -w 1 --bind <server_ip>:8080 wsgi
app.service file
[Service]
User=user
WorkingDirectory=/home/user/app
Environment="PATH=/home/user/app/app_venv/bin"
ExecStart=/home/user/app/app_venv/bin/gunicorn -k geventwebsocket.gunicorn.workers.GeventWebSocketWorker --workers 1 --bind <server_ip>:8080 wsgi
Python code that is generating the error
import subprocess
cmd = ['bash', 'script.sh' , args.get('arg')]
try:
process = subprocess.Popen(cmd,
cwd=/path/to/bash_script,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True)
while process.poll() is None:
output = process.stdout.readline()
if(output==''):
break
emit('tg_output', output)
except subprocess.CalledProcessError as error:
pass