I have a web-server that is based on flask+tornado combination. It works inside of a virtual environment (set up with python virtualenv).
I want the server to launch automatically on start up, from a regular user. What I have done to achieve this:
1) I have written a startup script with following contents:
cd /home/ubuntu/myserver
# enter virtualenv
source venv/bin/activate
# launch
python app.py > serverlog.log 2&>1 &
2) I have set up a crontab with crontab -e
as:
SHELL=/bin/bash
@reboot /home/ubuntu/start_service.sh
When I execute the startup script from the command line, everything is correctly launched. But after reboot in serverlog.log
I see a stacktrace that tells of failure to bind to port 5000. what can I do to fix it?