I am trying to run a flask app which uses octave and python oct2py package to communicate with Octave. I setup an python venv and am running the app.
Simple flask app seems to work fine as in it accepts Post requests and responds back. When I try to add the octave functionality, the app works fine. With direct gunicorn binding, the app works fine too.
Problem starts when I try to create systemd service
unit file and the code runs octave.
I created a service like /etc/systemd/system/my_project.service
and it's content as below.
[Unit]
Description=Gunicorn instance to serve flask app
After=network.target
[Service]
User=some_user
Group=www-data
WorkingDirectory=/home/some_user/project_dir
Environment="PATH=/home/some_user/project_dir/venv/bin"
ExecStart=/home/some_user/project_dir/venv/bin/gunicorn --workers 3 --bind unix:project_dir.sock -m 007 wsgi:app
[Install]
WantedBy=multi-user.target
After looking at the status it throws error like
After restarting the service it throws
gunicorn[1690]: self.restart()
gunicorn[1690]: File "/home/some_user/project_dir/venv/lib/python3.8/site-packages/oc>
gunicorn[1690]: self._engine = OctaveEngine(stdin_handler=self._handle_stdin,
gunicorn[1690]: File "/home/some_user/project_dir/venv/lib/python3.8/site-packages/oc>
gunicorn[1690]: self.executable = self._get_executable()
gunicorn[1690]: File "/home/some_user/project_dir/venv/lib/python3.8/site-packages/oc>
gunicorn[1690]: raise OSError('octave-cli not found, please see README')
gunicorn[1690]: OSError: octave-cli not found, please see README
systemd[1]: my_project.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: my_project.service: Failed with result 'exit-code'.
I searched many places for the error but couldn't get it resolved like here here
And for octave I tried running octave and octave-cli from terminal with and without venv active and it opens octave so I am unable to figure out the exact cause.
If I directly run the command on terminal, it runs the app without any error
gunicorn --bind 127.1.0.1:5000 wsgi:app
wsgi.py file looks like this
from my_project import app
if __name__ == "__main__":
app.run()
Any suggestion how to figure out this issue?