Python app down on Dreamhost
Last night, right before bed I decided to check out my websites hosted on Dreamhost real quick. (Bad idea, don’t do it right before bed.) To my surprise, instead of cute pics of my dog, I saw a fugly page with a stack trace I’ve never seen before.
Shocked, I got right onto it with debugging and googling. (Again, bad idea to do late at night.) In the end, till the next day, it took a bit more than a quick googling to find out what was going on. If you are in the same situation where you haven’t pushed anything new to the server but your web app is down, I hope this post helps.
Long story short, I’m running my Python app in a virtual environment on Dreamhost. Since Dreamhost recently upgraded their Python version, my virtual environment that was built on their older Python version broke. Snap!
Here’s the steps I took to revive my web apps:
- Login to dreamhost server.
cd
to the web app root directory. - Delete old virtual environment. Since I created the virtual environment at the root level, I had to delete all the folders generated by the old virtual environment. In my case, they were
bin
,include
,lib
, andlocal
. - Create new virtual environment. For future convenience, this time I created the virtual environment in a dedicated folder named ‘venv’ under the root, like so:
virtualenv venv
- Check if new virtual environment works. At root directory,
source venv/bin/activate
and my terminal turned into(venv)[servername]$
- Vim into passenger_wsgi.py and update the virtual environment’s path. Update ‘bin’ to ‘venv/bin’ in my case.
- Restart app by
touch tmp/restart.txt
After all the drama, my dog’s handsome face showed up again. (This place is for serious tech notes only. For cute doggie pictures, please visit www.brokentoystory.com)