Running in production
A few settings make a big difference once real traffic arrives. Work through this list before you go live.
Checklist
- Set options from the environment, not in code, so each environment can differ.
- Run at least two processes, so one can restart while the other keeps working.
- Send the logs to the same place as the rest of your application's logs.
- Pin the version in your lockfile and upgrade on purpose.
Shutting down cleanly
On shutdown, call close and wait for it, so work in progress finishes and nothing is lost:
import signal
import sys
def stop(signum, frame):
flags.close()
sys.exit(0)
signal.signal(signal.SIGTERM, stop)