Skip to content

Instantly share code, notes, and snippets.

@jerivas
Created April 10, 2017 00:54
Show Gist options
  • Save jerivas/0f7de62f04185db009eb8610f301c1e9 to your computer and use it in GitHub Desktop.
Save jerivas/0f7de62f04185db009eb8610f301c1e9 to your computer and use it in GitHub Desktop.

Bringing websites back up after server migrations

Hello! I created a quick guide to fix websites after a migration. Depending on the application type, the steps will differ.

Webfaction Django app

A regular Django / Apache app created from the control panel. Generally the only thing required is to reinstall the database driver (for either MySQL or Postgres) in the virtualenv. The virtualenv is a folder in the application directory, usually named *ENV. Just activate it and reinstall the DB driver from pip. Then restart from with apache2/bin/restart.

Custom Django app

We also use custom Django + memcache + gunicorn apps, and supervisor to manage gunicorn processes. If the application is of type "Custom":

  1. Locate and activate the virtualenv. It will be in ~/.virtualenvs and be named after the website record.

  2. Reinstall the DB adapter from pip (most likely using Postgres in these apps).

  3. If supervisor is not running: Run from the home directory:

    ~/bin/supervisord -c ~/etc/supervisord.conf

    You can install supervisord from the account-wide pip if it's not found. Only needs to be executed once per server.

  4. If memcache is not running: Run:

    memcached -d -m 50 -s ~/memcached.sock -P ~/memcached.pid

    Only needs to be executed once per server.

  5. Once supervisor is running and the virtualenv fixed, you can restart the site by running from home:

    supervisorctl restart gunicorn_<app name>

    Where <app name> is the name of the website record. If you receive no errors the site's back up! Otherwise you can check the logs at ~/logs/user/<app name>_error.log.

  6. To see which sites are running:

    supervisorctl status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment