Flask-socketio: How to run flask socketio on a PROD server

Created on 20 Jul 2020  路  2Comments  路  Source: miguelgrinberg/Flask-SocketIO

Your question
Hi,

I've installed eventlet as mentioned in the documentation. I have a server.py file which says:

app = Flask(__name__)
socketio = SocketIO(app, async_mode='eventlet')
if __name__ == '__main__':
    socketio.run(app, host='0.0.0.0')

To run the server I do:

nohup python3 server.py &

Is this the best way to run a server for Production?

question

Most helpful comment

I'm not sure it is the "best" way, but it is definitely a good way. I would not start the server just by running server.py though, instead I would create a systemd service file or similar, so that the process is monitored and restarted in the event of a power cycle or a crash.

All 2 comments

I'm not sure it is the "best" way, but it is definitely a good way. I would not start the server just by running server.py though, instead I would create a systemd service file or similar, so that the process is monitored and restarted in the event of a power cycle or a crash.

Thank you for your advice.
I tried creating a user service and will test it over the next few days.
Refer: https://github.com/torfsen/python-systemd-tutorial

Was this page helpful?
0 / 5 - 0 ratings