Skip to content

Workflows

StephenChan edited this page Oct 9, 2012 · 25 revisions

Git workflows

See the page on Git Workflows.

Updating code on the production server

Requirements before proceeding:

  • You will need a user account on your production server.
  • You may need to use sudo to have permission to run certain commands. For example, if apachectl start yields a "permission denied" error, then sudo apachectl start might work. To use sudo, you have to be added as a sudoer on the server.
    • Using sudo on git commands is generally a bad idea. See the below requirements to set up Git permissions with your production server username.
  • To use Git on the production server, you must have a Git credential helper or SSH key set up on the production server. See GitHub's guide for more info (make sure to select the server's operating system at the top of the page).
  • You will need write permission for the directories in the Git repository. To ensure that all project collaborators can write to the directories, you should make sure all of these directories have g+w (group write) permission and are under a group which all project collaborators are part of. Suppose your group is called coralnet-admin. Then you would run sudo chgrp -R coralnet-admin <path to project root> and sudo chmod -R g+w CoralNet.

Now, whenever you need to update code on the production server, you'd do the following:

  1. SSH into the production server machine, and locate the directory with the project code.
  2. Put up the maintenance message. Set the maintenance time to be at least several minutes after the current time. That way, users have some advance warning before you actually start messing with the site. (TODO: Link to documentation page on the maintenance message)
  3. Wait until your specified maintenance time begins. Then stop the server with apachectl stop. This is done because updating code while the server is running can temporarily leave the server code in an inconsistent state, which can lead to some very weird internal server errors. (Note that this is only the case when settings.DEBUG = False, which it should be for production servers.)
  4. Follow the Updating procedure on the Git workflows page. This'll be simple because you almost never develop code on the production server; you just update it. In particular, git fetch origin, git checkout -- <path to file>, and git rebase origin/master are probably all you will need.
  5. If there are any new Python packages or other packages to install, then install them.
  6. If there are any new settings to specify in settings_2.py, or new task helper functions to create in images/task_helpers.py, then do that.
  7. If any static files (CSS, Javascript, etc.) were changed, run python manage.py collectstatic to serve those new static files.
  8. If there are any new South migrations to run, then run those.
  9. Start the server again with apachectl start.
  10. Take down the maintenance message.

Resolving an internal server error

Running South migrations

Creating South migrations

Clone this wiki locally