How many times have you had the thrill of releasing a new service or app to the world, only to have it crashing down when you test the URL and find a server error page instead of your work? Here are a few tips I use when I'm trying to figure out why the new python service I have set up is not working:
Check server logsMany times, there's an error with the Apache config file. There's no guarantee that it'll show up in the logs, but it's a great place to start.
Create a python logIf it seems everything is working well from your server configuration, set up a temporary log in your file that handles the wsgi connection. Below is an example of a logger for a django app. Bold text shows the logging additions.
import logginglogging.basicConfig(filename="/path/to/newapp.log", level=logging.DEBUG)
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "website.settings.production")
application = get_wsgi_application()
logging.debug(application)
Opening a new terminal window and typing `tail -f /path/to/newapp.log` will give you a view into what's going on.
Sadly, this doesn't always provide a clear pointer to what's going on, but it's a great place to start.
And if you ever get an issue where the service is complaining that something is wrong in one of python's core modules, triple check that your application folder is set to accept traffic.
Require all grantedDo you have any other tips that work better than these? Please let me know !