Difference between revisions of "Software Life Cycle: 4. Updating The Production Servers"

From WormBaseWiki
Jump to navigationJump to search
m (Protected "Software Life Cycle: 4. Updating The Production Servers": DEPRECATED: MOVED TO GOOGLE DOCS ([edit=sysop] (indefinite) [move=sysop] (indefinite)))
 
(100 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
=Overview=
 
=Overview=
  
New releases of the web app and associated databases are staged on the development server. After testing, they are pushed into production.  Here is a summary of the main steps.
+
''This document describes the fourth and final stage of the WormBase software release cycle, moving new databases and software into production.  New releases of the web app and associated databases are staged on the development server. ''
  
# Check disk space and local and remote nodes: '''to do'''
+
The scripts that mediate production release are maintained in the git [https://github.com/WormBase/website-admin website-admin] repository.
# Purge old releases from local and remote nodes: '''to do'''
 
# Push new AceDB to AceDB nodes: cron_rsync_acedb.sh
 
# Push new MySQL databases to MySQL nodes: cron_rsync_mysql_dbs.sh
 
# Push new support databases: cron_rsync_support_dbs.sh
 
# Put the site into maintenance mode: '''to do'''
 
# Push updated version of the webapp: deploy_wormbase_webapp.sh VERSION
 
# Restart services: '''to do'''
 
# Restore the site to active mode: '''to do'''
 
# Make a blog post
 
# Send release email: '''to do (possibly via blog)'''
 
  
= The Web App =
+
= Steps=
  
== Software Release Cycle ==
+
== Check disk space on local and remote nodes ==
  
'''Development'''
+
Purge a specific release from production nodes. This need not be run every release but is useful to periodically clear out old builds.
  
Development occurs in private development sites, available at, eg, todd.wormbase.org. Each site is located in
+
Remove build WSXXX -- including acedb, mysql, and support DBs -- from the staging cluster:
 
+
  staging> website-admin/update/production/purge_old_releases.sh --release WSXXX --target staging
  wb-dev:/usr/local/wormbase/website/DEVNAME
 
  
''' QA/QC and staging '''
+
Remove build WSXXX -- including acedb, mysql, and support DBs -- from the production cluster:
 +
staging> admin/update/production/purge_old_releases.sh --release WSXXX --target production
  
QA/QC occurs on a version of the site staged for production, available at staging.wormbase.org, located at:
+
== Put the production site into maintenance mode ==
  
  wb-dev:/usr/local/wormbase/website/staging -> VERSION
+
'''TODO'''
  
''' Production '''
+
== Push databases to production nodes ==
  
Once QA/QC is complete, the staged version of the site is mirrored to cluster nodes by rsync. A copy of the staged site is saved on the development server for quick reference:
+
Push acedb, mysql, and support databases to production (or staging) nodes.
  
wb-dev:/usr/local/wormbase/website/production
+
  staging> ./steps/push_staged_release_to_nodes.pl --release $RELEASE --target production
  
== Checking out and building the code ==
+
== Update symlinks on production nodes ==
  
''For a new major release:''
+
''We use symlinks to point to the most current versions of acedb and mysql databases in both production and on the FTP site.  These need to be adjusted prior to going live.''
  
  ssh wb-dev
+
  staging> ./steps/adjust_symlinks.pl --release WSXXX --target production
cd /usr/local/wormbase/website
 
// Anonymously checkout the code. You will not be able to commit back...
 
hg clone ssh://hg@bitbucket.org/tharris/wormbase
 
mv wormbase staging
 
  
''Build dependencies.''
 
cd staging
 
mkdir extlib
 
cd extlib
 
perl -Mlocal::lib=./
 
eval $(perl -Mlocal::lib=./)
 
cd ../
 
perl Makefile.PL
 
make installdeps
 
 
Update wormbase.env to read "APPNAME=production", then
 
source wormbase.env
 
  
''For an updated but minor release:''
+
== Deploy the web app ==
  
cd /usr/local/wormbase/website/staging
+
Run deploy_webapp.pl from any WormBase host to push a new software version into productionThis script:
hg incoming
 
hg pull -u
 
perl Makefile.PL
 
  make installdeps    // make sure we are up-to-date
 
  
 +
# gets the current major version of the webapp from lib/WormBase/Web.pm
 +
# gets the number of commits for the source in wb-dev:website/staging since the last tag
 +
# creates a VERSION.txt in the staging directory
 +
# backs up the production/ directory on each node to archive/VERSION_STRING for easy rollbacks
 +
# visits each staging or production host and pulls the specified branch.
 +
# send a HUP to starman on remote nodes forcing a graceful restart of all workers
 +
# creates a software release on the FTP site, and symlinks current.tgz to it
 +
# copies the staged code to wb-dev:/usr/local/wormbase/website/production.current" for easy reference
 +
# Minimizes javascript and CSS via UglifyJS
  
== Build the user schema ==
+
staging> website-admin/update/production/steps/deploy_webapp.sh --release WSXXX --target production|staging
  
''The website uses a mysql backend to store user preferences, browsing history, session data.  This shouldn't ever need to be recreated (at least until we have a migration path in place from an old database to a new one!), but here's how to create it for reference. For now, this database is hosted on web1.
+
Every push to production is
 +
: tied to a version of the database
 +
: tied to a major version of the webapp
 +
: tied to a revision corresponding to the number of commits since the last tag
 +
<pre>
 +
        Date            # of commits since WS221 tag
 +
        |                |
 +
  WS221-2010.12.24-v0.02r0
 +
  |                |
 +
  Acedb version          Major software version
 +
</pre>
  
ssh web1
+
=== Working with git branches ===
cd /usr/local/wormbase/website/production
 
mysql -u root -p
 
mysql> parse /usr/local/wormbase/website/production/
 
  
= Releasing a new build =
+
We develop code for each release on the master branch.  Once ready, these changes are then push/pulled to the "production" branch.
  
''New builds of the database are staged on wb-dev. Appropriate scripts are in the private wormbase-admin mercurial module.''
+
Bug fixes are made on the "production" branch and merged from production -> master.
  
== Purge old builds ==
+
Tags are used to denote specific releases.
  
Purge a specific release from production nodes. This need to be run every release but is useful to periodically clear out old builds.
+
For reference, here is how the production branch was created.
 +
shell> git branch --track production origin/master
 +
shell> git checkout production
  
Remove build WSXXX, including acedb, mysql, and support DBs
+
To work on a branch:
  wb-dev> admin/update/production/purge_old_releases.sh WSXXX
+
  shell> cd /path/to/your/repository
 +
shell> git pull
 +
shell> git checkout [production|master]
 +
shell> git branch // to see which branch you are working on.
 +
shell> git branch -a // to list all local branches.
  
Remove build WSXXX from localhost (ie the dev server), including acedb, mysql, and support DBs
+
To make a bug fix to production:
  wb-dev> admin/update/production/purge_old_releases.sh WSXXX local
+
  shell> cd /path/to/your/repository
 +
shell> git checkout production
 +
... write code of heart breaking beauty and humble economy ...
 +
shell> git commit -m 'just resolved all the issues'
 +
shell> git push
 +
shell> git checkout master
 +
shell> git merge production
  
== Push out Acedb ==
+
To create an annotated release tag:
 +
shell> cd /path/to/your/repository
 +
shell> git tag -a WS500 -m 'release of WormBase WS500'
 +
shell> git push origin WS500  // push the remote tag to origin
 +
shell> git show WS500 // list all information about the annotated tag.
  
The Acedb data directory is kept in sync by cron:
+
== Restart services ==
 +
 
 +
''Starman and AceDB need to be restarted on remote nodes.''
 +
 
 +
staging> ./steps/restart_starman.pl WSXXX    // this only restarts starman
 +
staging> ./steps/restart_services.pl WSXXX    // starman + sgifaceserver
 +
 
 +
== Update symlinks on the FTP site ==
 +
 
 +
''On the production FTP server, run:''
 +
 
 +
wb-dev> ./steps/update_production_ftp_site_symlinks.pl --release WSXXX
 +
 
 +
== Manual steps ==
 +
 
 +
Manually:
 +
 
 +
* Update release notes on wiki
 +
* Send announcement
 +
 
 +
=== Installing a new assemblies metadata file ===
 +
 
 +
Get the metadata file for a particular WormBase release:
 +
 
 +
<pre>
 +
./website/script/get_assemblies_metadata.sh *VERSION*
 +
</pre>
 +
 
 +
''Example:''
 +
 
 +
<pre>
 +
./website/script/get_assemblies_metadata.sh WS240
 +
</pre>
 +
 
 +
Add the metadata file to the repo:
 +
 
 +
<pre>
 +
cd website
 +
git add metadata/ASSEMBLIES.*VERSION*.json
 +
git commit metadata/ASSEMBLIES.*VERSION*.json
 +
git push
 +
</pre>
 +
 
 +
''Example:''
 +
 
 +
<pre>
 +
cd website
 +
git add metadata/ASSEMBLIES.WS240.json
 +
git commit metadata/ASSEMBLIES.WS240.json
 +
git push
 +
</pre>
 +
 
 +
=== Post a blog entry announcing the new release ===
 +
 
 +
''Posting a blog entry on [http://blog.wormbase.org/wp-admin/ blog.wormbase.org] will cross-feed to our social media outlets as well as add a news item to the front page.''
 +
 
 +
== Restore the production site into maintenance mode ==
 +
 
 +
'''TODO'''
 +
 
 +
 
 +
 
 +
----
  
wb-dev> cron_rsync_acedb.sh
 
  
== Push out MySQL ==
+
= Appendices =
  
''Originally intended to be run as a cron job, it's less error prone to push databases out when they are ready to go.''
+
== Appendix 1: Pushing Acedb independently ==
  
wb-dev> cron_rsync_mysql_dbs.sh WSXXX
+
Push acedb into production via a tarball, a single unpacked acedb database directory, or all acedb/wormbase* directories.
  
== Deploy software ==
+
    To run it under cron syncing ALL acedb/wormbase_* directories:
 +
      ./push_acedb.pl --method all_directories
  
''Deployment is handled automatically by a script in the wormbase-admin module:
+
    To push out a single release using a tarball:
 +
      ./push_acedb.pl --method by_package --release WSXXX
  
wb-dev:admin/update/production/deploy_wormbase_app.sh WSXXX
+
    To push out a single release by rsyncing the directory:
 +
      ./push_acedb.pl --method by_directory --release WSXXX
  
* Reads the current version of the code in the staging/ directory.
+
== Appendix 2: Pushing support databases independently ==
* Rsyncs that directory to each web node in cluster:/usr/local/wormbase/website/$VERSION
 
* Updates the symlink on cluster:/usr/local/wormbase/website/production -> $VERSION
 
* Creates a release of the software (should it branch/tag, too?) to the releases directory and the FTP site.
 
  
wb-dev:/usr/local/wormbase/website/releases/YYYY-MM-DD-$WORMBASEVERSION-$VERSION-YYYY-MM-DD
+
TODO:
 +
Add FIFO to accelerate synchronization
 +
http://engineering.tumblr.com/post/7658008285/efficiently-copying-files-to-multiple-destinations
  
* Creates a reference version of the production site for easy access on the dev server at:
+
UPDATE: The *best* way to do this is probably tar the dir
 +
(not gzip it) and send it over the wire:
 +
tar -c /path/to/dir | ssh remote_server 'tar -xvf - -C /absolute/path/to/remotedir'
  
  wb-dev:/usr/local/wormbase/website/production
+
Or Rsync:
 +
  rsync -avW -e ssh /path/to/dir/ remote_server:/path/to/remotedir
  
== Restart services ==
+
The default -- and hard-coded -- behavior is to sync the local support databases directory to our ${NFS mount}/shared/databases. Other options include via a tarball, a single database directory, or all current support database directories.
 +
 
 +
# Start after the build deadline date
 +
0 3 12-31 * * /home/tharris/projects/wormbase/website-admin/update/production/steps/push_support_databases.pl
 +
 
 +
To run it under cron syncing ALL database/WS* directories:
 +
      ./push_support_databases.pl --method all_directories
 +
 
 +
To push out a single release using a tarball:
 +
      ./push_support_databases.pl --method by_package --release WSXXX
 +
 
 +
To push out a single release by rsyncing the directory:
 +
      ./push_support_databases.pl --method by_directory --release WSXXX
 +
 
 +
For additional information:
 +
  ./push_support_databases.pl --help
 +
 
 +
== Appendix 3: Pushing MySQL databases independently ==
 +
 
 +
Push mysql databases into production via a tarball or by syncing individual unpacked database directories.
 +
 
 +
    Preferred: push out a single release by rsyncing individual databases:
 +
    ./push_mysql_databases.pl --method by_directory --release WSXXX
 +
 
 +
    To push out a single release using a tarball:
 +
      ./push_mysql_databases.pl --method by_package --release WSXXX
 +
 
 +
 
 +
== Appendix 4. Minimizing Javascript and CSS ==
 +
 
 +
On the development server, install UglifyJS
 +
<pre>
  
 +
# clone the repository
 +
mkdir -p /usr/local/wormbase/services/uglifyJS
 +
cd /usr/local/wormbase/services/uglifyJS
 +
git clone git://github.com/mishoo/UglifyJS.git
  
 +
# make the module available to Node
 +
mkdir -p ~/.node_libraries/
 +
cd ~/.node_libraries/
 +
ln -s /where/you/wanna/put/it/UglifyJS/uglify-js.js
  
 +
# and if you want the CLI script too:
 +
mkdir -p ~/bin
 +
cd ~/bin
 +
ln -s /where/you/wanna/put/it/UglifyJS/bin/uglifyjs
 +
  # (then add ~/bin to your $PATH if it's not there already)
 +
</pre>
  
  
  
 
[[Category:Developer documentation]]
 
[[Category:Developer documentation]]

Latest revision as of 16:17, 30 December 2013

Overview

This document describes the fourth and final stage of the WormBase software release cycle, moving new databases and software into production. New releases of the web app and associated databases are staged on the development server.

The scripts that mediate production release are maintained in the git website-admin repository.

Steps

Check disk space on local and remote nodes

Purge a specific release from production nodes. This need not be run every release but is useful to periodically clear out old builds.

Remove build WSXXX -- including acedb, mysql, and support DBs -- from the staging cluster:

staging> website-admin/update/production/purge_old_releases.sh --release WSXXX --target staging

Remove build WSXXX -- including acedb, mysql, and support DBs -- from the production cluster:

staging> admin/update/production/purge_old_releases.sh --release WSXXX --target production

Put the production site into maintenance mode

TODO

Push databases to production nodes

Push acedb, mysql, and support databases to production (or staging) nodes.

 staging> ./steps/push_staged_release_to_nodes.pl --release $RELEASE --target production

Update symlinks on production nodes

We use symlinks to point to the most current versions of acedb and mysql databases in both production and on the FTP site. These need to be adjusted prior to going live.

staging> ./steps/adjust_symlinks.pl --release WSXXX --target production


Deploy the web app

Run deploy_webapp.pl from any WormBase host to push a new software version into production. This script:

  1. gets the current major version of the webapp from lib/WormBase/Web.pm
  2. gets the number of commits for the source in wb-dev:website/staging since the last tag
  3. creates a VERSION.txt in the staging directory
  4. backs up the production/ directory on each node to archive/VERSION_STRING for easy rollbacks
  5. visits each staging or production host and pulls the specified branch.
  6. send a HUP to starman on remote nodes forcing a graceful restart of all workers
  7. creates a software release on the FTP site, and symlinks current.tgz to it
  8. copies the staged code to wb-dev:/usr/local/wormbase/website/production.current" for easy reference
  9. Minimizes javascript and CSS via UglifyJS
staging> website-admin/update/production/steps/deploy_webapp.sh --release WSXXX --target production|staging

Every push to production is

tied to a version of the database
tied to a major version of the webapp
tied to a revision corresponding to the number of commits since the last tag
         Date            # of commits since WS221 tag
         |                |
   WS221-2010.12.24-v0.02r0
   |                 |
   Acedb version           Major software version

Working with git branches

We develop code for each release on the master branch. Once ready, these changes are then push/pulled to the "production" branch.

Bug fixes are made on the "production" branch and merged from production -> master.

Tags are used to denote specific releases.

For reference, here is how the production branch was created.

shell> git branch --track production origin/master
shell> git checkout production

To work on a branch:

shell> cd /path/to/your/repository
shell> git pull
shell> git checkout [production|master]
shell> git branch // to see which branch you are working on.
shell> git branch -a // to list all local branches.

To make a bug fix to production:

shell> cd /path/to/your/repository
shell> git checkout production
... write code of heart breaking beauty and humble economy ...
shell> git commit -m 'just resolved all the issues'
shell> git push
shell> git checkout master
shell> git merge production

To create an annotated release tag:

shell> cd /path/to/your/repository
shell> git tag -a WS500 -m 'release of WormBase WS500'
shell> git push origin WS500   // push the remote tag to origin
shell> git show WS500 // list all information about the annotated tag.

Restart services

Starman and AceDB need to be restarted on remote nodes.

staging> ./steps/restart_starman.pl WSXXX     // this only restarts starman
staging> ./steps/restart_services.pl WSXXX     // starman + sgifaceserver

Update symlinks on the FTP site

On the production FTP server, run:

wb-dev> ./steps/update_production_ftp_site_symlinks.pl --release WSXXX

Manual steps

Manually:

  • Update release notes on wiki
  • Send announcement

Installing a new assemblies metadata file

Get the metadata file for a particular WormBase release:

./website/script/get_assemblies_metadata.sh *VERSION*

Example:

./website/script/get_assemblies_metadata.sh WS240

Add the metadata file to the repo:

cd website
git add metadata/ASSEMBLIES.*VERSION*.json
git commit metadata/ASSEMBLIES.*VERSION*.json
git push

Example:

cd website
git add metadata/ASSEMBLIES.WS240.json
git commit metadata/ASSEMBLIES.WS240.json
git push

Post a blog entry announcing the new release

Posting a blog entry on blog.wormbase.org will cross-feed to our social media outlets as well as add a news item to the front page.

Restore the production site into maintenance mode

TODO




Appendices

Appendix 1: Pushing Acedb independently

Push acedb into production via a tarball, a single unpacked acedb database directory, or all acedb/wormbase* directories.

   To run it under cron syncing ALL acedb/wormbase_* directories:
      ./push_acedb.pl --method all_directories
   To push out a single release using a tarball:
      ./push_acedb.pl --method by_package --release WSXXX
   To push out a single release by rsyncing the directory:
      ./push_acedb.pl --method by_directory --release WSXXX

Appendix 2: Pushing support databases independently

TODO: Add FIFO to accelerate synchronization http://engineering.tumblr.com/post/7658008285/efficiently-copying-files-to-multiple-destinations

UPDATE: The *best* way to do this is probably tar the dir (not gzip it) and send it over the wire:

tar -c /path/to/dir | ssh remote_server 'tar -xvf - -C /absolute/path/to/remotedir'

Or Rsync:

rsync -avW -e ssh /path/to/dir/ remote_server:/path/to/remotedir

The default -- and hard-coded -- behavior is to sync the local support databases directory to our ${NFS mount}/shared/databases. Other options include via a tarball, a single database directory, or all current support database directories.

  1. Start after the build deadline date

0 3 12-31 * * /home/tharris/projects/wormbase/website-admin/update/production/steps/push_support_databases.pl

To run it under cron syncing ALL database/WS* directories:

      ./push_support_databases.pl --method all_directories

To push out a single release using a tarball:

      ./push_support_databases.pl --method by_package --release WSXXX

To push out a single release by rsyncing the directory:

      ./push_support_databases.pl --method by_directory --release WSXXX

For additional information:

  ./push_support_databases.pl --help

Appendix 3: Pushing MySQL databases independently

Push mysql databases into production via a tarball or by syncing individual unpacked database directories.

   Preferred: push out a single release by rsyncing individual databases:
    ./push_mysql_databases.pl --method by_directory --release WSXXX
   To push out a single release using a tarball:
      ./push_mysql_databases.pl --method by_package --release WSXXX


Appendix 4. Minimizing Javascript and CSS

On the development server, install UglifyJS


# clone the repository
mkdir -p /usr/local/wormbase/services/uglifyJS
cd /usr/local/wormbase/services/uglifyJS
git clone git://github.com/mishoo/UglifyJS.git

# make the module available to Node
mkdir -p ~/.node_libraries/
cd ~/.node_libraries/
ln -s /where/you/wanna/put/it/UglifyJS/uglify-js.js

# and if you want the CLI script too:
mkdir -p ~/bin
cd ~/bin
ln -s /where/you/wanna/put/it/UglifyJS/bin/uglifyjs
  # (then add ~/bin to your $PATH if it's not there already)