python - Can't run Flask app with gunicorn like service -


i'm trying make service run flask app gunicorn. service file this:

[unit] description=metrofind after=network.target  [service] user=ubuntu group=ubuntu restart=on-failure workingdirectory=/home/ubuntu/geometrofinding/ execstart=/home/ubuntu/geometrofinding/flaskenv/bin/gunicorn -c /home/ubuntu/geometrofinding/gunicorn.conf -b 0.0.0.0:5000 main_flask:app  [install] wantedby=multi-user.target 

in log-error file writes:

importerror: no module named 'pandas' 

or

importerror: no module named 'main_flask' 

but in virtual env, necessary packages installed.

and when run locally directory "geometrofinding" in console command:

  gunicorn -c gunicorn.conf -b 0.0.0.0:5000 main_flask:app 

app running

what wrong?

you have set environment in service file.

an example of [service] section this:

[service] user=ubuntu group=ubuntu restart=on-failure workingdirectory=/home/ubuntu/geometrofinding/ environment="path=/home/ubuntu/geometrofinding/flaskenv/bin" execstart=/home/ubuntu/geometrofinding/flaskenv/bin/gunicorn -c /home/ubuntu/geometrofinding/gunicorn.conf -b 0.0.0.0:5000 main_flask:app 

so need add environment path in order make work.

take @ this great tutorial more info.


Comments

Popular posts from this blog

javascript - How to split the success output from an Ajax post? -

sql - Time in datatime field -

c# - Sending messages from UWP to socket.io -