When I launch the default Flask development server, I get this warning
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
As a result, there are some options to overcome this. You can use a package called Waitress as documented in the offical Flask documents
But this is the best answer with coding samples embedded in your Flask server code
One option is to use Waitress, a production WSGI server. Other servers include Gunicorn and uWSGI.
For my MacOS, the above does not work it seems with the serve package portion not to be found. Waitress appeears to work on CentOS 7 Linux. This includes these Python import commands:
from waitress import serve
These are WSGI alternatives to Waitress
As a result, I am trying
This links appears to work fine with an introduction to set up as a service within your Linux environment. This uses Gunicorn.
Also, my hosting provider KnownHos preferred me to use daemons/service instead
This GitHub post recommended to pip install systemd. This failed both on my Mac environment and regular user Linux account. It installed fine with root access.
Another tech at my hosting company suggested setting up a Python service with
How To Setup Autorun a Python Script Using Systemd
Note the comment of:
A fine and simple to follow tutorial. I would add a couple of caveats – with the .service file as written the python script will be run as root and this may have unintended consequences. Also the environment will be different from that for a normal user. To fix add the lines User=username and Group=groupname before the ExecStart line. To add environment variables expected by the script add the line Environment=”variable_name=variable_value” before the ExecStart line.
to run as non root follow
Is Google PubSub better ?
Get some free tech trading book https://quantlabs.net/
Talk to me about your trading https://quantlabs.net/questions/
Get lifetime access to our private chart server? https://quantlabs.net/dvd/
I now post my TRADING ALERTS
into my personal FACEBOOK ACCOUNT
. Don't worry as I don't post stupid cat videos or what I eat!