Dev Maintenance

From Dreamwidth Notes
Revision as of 14:56, 14 May 2016 by Me and (Talk | contribs)

Jump to: navigation, search

Updating the Dreamwidth code on your Dreamhack

Shutting down apache

It is best to shut your Apache instance down before doing the update process, to make sure that everything, especially scripts in cgi-bin/ are reloaded properly:

stop-apache

Updating dw-free

Okay. Let's say you've been running your Dreamwidth install and you want to pull down the latest and greatest in fixes. This is pretty easy. First, if you are not somewhere in dw-free, get into that directory:

cd $LJHOME

Then grab updates from the development branch of Dreamwidth's repository:

git fetch dreamwidth
git checkout develop && git pull --ff-only dreamwidth develop:develop

You will also want to push the Dreamwidth repository changes to your fork on Github:

git push origin develop

If you have uncommitted changes, you'll get an error message and will need to use git stash.


For those using DW non-free

Repeat for dw-nonfree:

cd $LJHOME/ext/dw-nonfree

git fetch dreamwidth
git checkout develop && git pull --ff-only dreamwidth develop:develop
git push origin develop

Update your database

Now that your code has been updated, update the database:

# order of commands is important
$LJHOME/bin/upgrading/update-db.pl -r -p --innodb
$LJHOME/bin/upgrading/update-db.pl -r --cluster=all --innodb
$LJHOME/bin/upgrading/texttool.pl load

Remember that different branches might have different text strings you have added, and that you might need to update your database for different branches when you are working on them for those text strings to work. The same applies for any database changes made by different branches you are working on.

Compile the SCSS

You'll also want to compile any changes to the SCSS into CSS for dw-free:

cd $LJHOME
compass compile
# And dw-nonfree if you are using it:
cd $LJHOME/ext/dw-nonfree
compass compile

Restart the server

Now you can restart Apache:

start-apache

Of course, in a production environment, this whole process is not too recommended as you never know what kind of code you're going to get. But for the most part, it's fairly straightforward. (And if you're doing development, this is generally safe.)

Additional Information for Non-Dreamhack Users

This section is only for you if you're running your own installation.

Instead of using start-apache/stop-apache, which are Dreamhack-specific scripts, use these commands:

sudo /etc/init.d/apache2 start
sudo /etc/init.d/apache2 stop 

You'll also want to update packages on your system at some point. On Ubuntu, this would be done using:

apt-get update
apt-get upgrade

Or, if you want an easy command to run on your dw account in one swoop:

sudo apt-get update && sudo apt-get upgrade

Scripting

Warning: "These scripts have not been thoroughly tested yet with the new system; they might not be updated entirely or right."

You can, of course, use scripts to make it easier for you to do some of this.

There is an epic "omnibus" script by [info]jeshyr available at http://dw-dev.dreamwidth.org/94822.html which incorporates all the individual scripts listed here and some other useful functions, and includes help information. It'll save you a heap of angst as a beginner!

Some simpler example scripts are given below.

dwu - Updating the repos

Put this code in a file called ~/bin/dwu and make it executable with chmod ugo+x ~/bin/dwu:

#!/bin/bash
 
# make sure we are in the right directory;
cd $LJHOME
 
git fetch dreamwidth
 
# pull changes from dreamwidth
git checkout develop
git pull --ff-only dreamwidth develop
 
# push them to Github forks
git push origin develop
 
# restore our old position
git checkout -
 
# check to see if we have a dw-nonfree directory; if we do, update that too
if [ -d "$LJHOME/ext/dw-nonfree" ]; then
  # change to dw-nonfree
  cd $LJHOME/ext/dw-nonfree
 
  git fetch dreamwidth
 
  # pull changes from dw-nonfree
  git checkout develop
  git pull --ff-only dreamwidth develop
 
  # push them to Github forks
  git push origin develop
 
  # restore our old position
  git checkout -
fi

Now, when you type 'dwu', this script will update your dw-free and (if you have it) dw-nonfree repositories.

dwdb - Updating the database

Put this code in a file called ~/bin/dwdb and make it executable with chmod ugo+x ~/bin/dwdb:

#!/bin/bash
$LJHOME/bin/upgrading/update-db.pl -r -p --innodb &&
$LJHOME/bin/upgrading/update-db.pl -r --cluster=all --innodb &&
$LJHOME/bin/upgrading/texttool.pl load

This will update the database when you type 'dwdb'.

comp - Recompiling the compass files

Put this code in a file called "'~/bin/comp'" and make it executable with "'chmod ugo+x ~/bin/comp'":

#!/bin/bash
cd "$LJHOME" &&
compass compile &&
cd ext/dw-nonfree &&
compass compile

This will recompile the CSS files.

Cleaning up your directories

If you do any amount of work, you'll find that your directories get cluttered with .orig and .rej files everywhere. This script will clean those up:

git clean -f "*.rej" "*.orig"

You can run it from the command line, or put it in a file called ~/bin/tidy and make it executable with "chmod +x ~/bin/tidy". If you do that, you'll be able to just type "tidy" to clean house.