Difference between revisions of "Dev Maintenance"

From Dreamwidth Notes
Jump to: navigation, search
Line 11: Line 11:
 
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.
 
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.
  
You should be making all your changes on branches, leaving the main develop and master branches alone. If you have any uncommitted changes, first save them:
+
  git pull dreamwidth develop:develop
  
cd $LJHOME
+
Then grab updates from the development and master branches of Dreamwidth's repository:
git stash
+
  
You will want to note what branch you are on, too, if you are currently working on one. It will be starred when you run:
+
git pull dreamwidth develop:develop
 +
git pull dreamwidth master:master
 +
 
 +
You will also want to push the Dreamwidth repository changes to your fork on Github:
 +
 
 +
  git push origin develop
 +
git push origin master
 +
 
 +
=== Merge the changes with your branch(es) ===
 +
 
 +
You should be doing your development in branches separate from the main Dreamwidth branches.  You can check what branches you currently have in your repository with the command:
  
 
  git branch
 
  git branch
  
Then grab updates from the development branch of Dreamwidth's repository:
+
The current branch will have an asterisk next to it.  Here is an example:
  
  git checkout develop
+
  yourhack@dreamhack.net:~/dw$ git branch
  git pull dreamwidth
+
  develop
 +
  * feature/Mobile
 +
  master
  
You will also want to push the Dreamwidth develop changes to your fork on Github:
+
You can change branches with <tt>git checkout BRANCH</tt>, example:
  
  git push origin develop
+
  git checkout feature/Mobile
 +
 
 +
You will need to merge your independent branches with the changes made with Dreamwidth's development branch:
  
To restore your saved changes (if you made any), get back to the branch you were on:
+
git merge develop
  
git checkout BRANCH
+
=== For those using DW non-free ===
git stash pop
+
  
 
Repeat for dw-nonfree:
 
Repeat for dw-nonfree:
  
 
  cd $LJHOME/ext/dw-nonfree
 
  cd $LJHOME/ext/dw-nonfree
git stash
 
 
   
 
   
# note what branch you are on
+
  git pull dreamwidth develop:develop
  git branch
+
  git pull dreamwidth master:master
+
git checkout develop
+
  git pull
+
 
  git push origin develop
 
  git push origin develop
+
  git push origin master
  git checkout BRANCH
+
git stash pop
+
  
 
Update your database:
 
Update your database:
  
    # order of commands is important
+
# order of commands is important
    $LJHOME/bin/upgrading/update-db.pl -r -p --innodb
+
$LJHOME/bin/upgrading/update-db.pl -r -p --innodb
    $LJHOME/bin/upgrading/update-db.pl -r --cluster=all --innodb
+
$LJHOME/bin/upgrading/update-db.pl -r --cluster=all --innodb
    $LJHOME/bin/upgrading/texttool.pl load
+
$LJHOME/bin/upgrading/texttool.pl load
  
 
Now you can restart Apache:
 
Now you can restart Apache:
Line 68: Line 74:
 
Instead of using start-apache/stop-apache, which are Dreamhack-specific scripts, use these commands:
 
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 start
    sudo /etc/init.d/apache2 stop  
+
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:
 
You'll also want to update packages on your system at some point. On Ubuntu, this would be done using:
Line 111: Line 117:
 
cd $oldpwd
 
cd $oldpwd
 
</source>
 
</source>
 
  
 
=== dwdb - Updating the database ===
 
=== dwdb - Updating the database ===

Revision as of 17:31, 24 August 2012

Note: "We're in the middle of moving over to a git workflow. If you haven't yet moved over to git, see the old instructions. If you're looking to move over, first make sure you've finished Moving your Dreamwidth installation to use Github"

Updating the Dreamwidth code on your Dreamhack

Warning: VERY IMPORTANT: If you have custom changes that you have not committed or patched out, you want to do that first! This is very easy. Just use git stash to save your work before you start, and recover it after you're done.

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

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.

git pull dreamwidth develop:develop

Then grab updates from the development and master branches of Dreamwidth's repository:

git pull dreamwidth develop:develop
git pull dreamwidth master:master

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

git push origin develop
git push origin master

Merge the changes with your branch(es)

You should be doing your development in branches separate from the main Dreamwidth branches. You can check what branches you currently have in your repository with the command:

git branch

The current branch will have an asterisk next to it. Here is an example:

yourhack@dreamhack.net:~/dw$ git branch
  develop
* feature/Mobile
  master

You can change branches with git checkout BRANCH, example:

git checkout feature/Mobile

You will need to merge your independent branches with the changes made with Dreamwidth's development branch:

git merge develop

For those using DW non-free

Repeat for dw-nonfree:

cd $LJHOME/ext/dw-nonfree

git pull dreamwidth develop:develop
git pull dreamwidth master:master
git push origin develop
git push origin master

Update your 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

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 throughly 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 most of this.

There is an "omnibus" script available at http://dw-dev.dreamwidth.org/94822.html which incorporates all the individual scripts listed here and some other functions, and includes help information.

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
oldpwd=$PWD && \
cd $LJHOME && \
git pull dreamwidth develop && \
cd $oldpwd

Now, when you type 'dwu', this script will update dw-free. If you need to update dw-nonfree as well, then use this code:

#!/bin/bash
oldpwd=$PWD && \
cd $LJHOME && \
git pull && \
cd $LJHOME/ext/dw-nonfree && \
git pull && \
cd $oldpwd

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'.

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.