From: fess <fe...@us...> - 2004-01-20 00:07:04
|
Update of /cvsroot/wigwam/wigwam-base/bin-scripts In directory sc8-pr-cvs1:/tmp/cvs-serv13390/bin-scripts Modified Files: Tag: fess_pubtool_locking pubtool Log Message: quickly dropped in the long requested publish locking feature. on a branch. testing it in a project by hand. Index: pubtool =================================================================== RCS file: /cvsroot/wigwam/wigwam-base/bin-scripts/pubtool,v retrieving revision 1.17 retrieving revision 1.17.2.1 diff -u -r1.17 -r1.17.2.1 --- pubtool 17 Oct 2003 23:24:38 -0000 1.17 +++ pubtool 20 Jan 2004 00:07:01 -0000 1.17.2.1 @@ -48,6 +48,8 @@ diff Generate a \`cvs diff' between two versions. publish Publish a version of the site to the cluster stage Update the site on your local computer. + lock manually lock a cluster for publishing. + unlock manually unlock a cluster. Run \`$id COMMAND --help' for help on a particular command. @@ -112,6 +114,20 @@ $TAG_SPECIFICATION_usage" +usage_lock="usage: $id lock CLUSTER + +manually run the lock command used when locking a cluster for publishing + +" + +usage_unlock="usage: $id unlock CLUSTER + +manually run the unlock command used when unlocking a cluster for publishing +somtimes this is needed if you've left a stale lock around. + +" + + usage_stage="usage: $id stage [TAG-SPECIFICATION] Update a site on your local machine. @@ -135,6 +151,37 @@ fi } +# publish_lock_cluster_helper cluster master_dir admin_op op_name +_publish_lock_cluster_helper () { + current_dir=`pwd` + ret=0 + test -z "$2" || cd "$2" + if test -r "etc/clusters/$1/hosts"; then + cvs -q admin "$3" "etc/clusters/$1/hosts" >/dev/null + test "$?" = 0 || { + echo >&2 "$id publish_${op_name}_cluster(): cvs lock failed for ${1}!"; + ret=1 + } + else + echo >&2 "$id publish_${op_name}_cluster(): hosts file does not exist for ${1}!"; + ret=1 + fi + cd "$current_dir" + return $ret; +} + +# publish_lock_cluster cluster master_dir +publish_lock_cluster () { + _publish_lock_cluster_helper "$1" "$2" "-l1.1" "lock" +} + +# publish_unlock_cluster cluster master_dir +publish_unlock_cluster () { + _publish_lock_cluster_helper "$1" "$2" "-u1.1" "unlock" +} + +### + # support environment variable override for the table of error messages. if test "x$WPARALLELIZER_ERROR_TABLE_FILE" = x ; then wparallelizer_error_table_opts="" @@ -233,7 +280,7 @@ command="$1" fi case "$command" in - rtag | tag | changes | diff | publish | stage) + rtag | tag | changes | diff | publish | stage | lock | unlock ) ;; *) echo "$id: Unknown command: \`$command'" 1>&2 @@ -369,11 +416,16 @@ unknown=1 ;; esac - if test "$unknown" = 1 && - test "$command" = "publish" && - test "x$cluster_name" = "x" ; then - cluster_name="$1" - unknown=0 + + if test "$unknown" = 1; then + case "$command" in + publish | unlock | lock ) + if test "x$cluster_name" = "x" ; then + cluster_name="$1" + unknown=0 + fi + ;; + esac fi if test "$unknown" = 1 ; then @@ -414,6 +466,10 @@ publish) tag_prefix_cluster="$cluster_name" ;; + lock | unlock) + tag_prefix=not_needed + tag=not_needed + ;; changes | diff | tag | rtag) if test -r "$PLAYPEN_ROOT/etc/cluster" ; then tag_prefix_cluster=`cat "$PLAYPEN_ROOT/etc/cluster"` @@ -448,6 +504,7 @@ tag=HEAD fi + #--------------------------------------------------------------------- # Compute the appropriate tag-name. if test "x$tag" = "x" ; then @@ -543,6 +600,18 @@ run-configurable bin/publish/interpret-cvs-update-output ;; + unlock) + # + publish_unlock_cluster "$cluster_name" "$PLAYPEN_ROOT" && + echo "unlocked $cluster_name." + + ;; + + lock) + publish_lock_cluster "$cluster_name" "$PLAYPEN_ROOT" && + echo "locked $cluster_name." + ;; + stage) # _ # ___| |_ __ _ __ _ ___ @@ -715,22 +784,6 @@ has_use=0 has_postpub=0 - # 1.1. Verify that the clusters' roles are ready to publish. - # XXX: this code cannot work, b/c master_dir isn't built. - # (and shouldn't be...) so this MUST be moved to prepare-new-playpen. -# ( -# . "$PLAYPEN_ROOT/ext/bin/unsetup-env" -# test "x$PLAYPEN_ROOT" = x || { -# echo "$id: unsetup-env failed." 1>&2 -# exit 1 -# } -# "$master_dir"/ext/bin/servicectl check-config cluster "$cluster_name" || { -# echo "$id: some environment variables aren't set," \ -# "consult above errors." 1>&2 -# exit 1 -# } -# ) || exit 1 - # 2. Make scripts (they will be used as input to wparallelizer) # run-precheck Verify that publication should work # w/ permissions etc. @@ -999,6 +1052,11 @@ esac done + echo "$id: getting publish lock for $cluster_name." + publish_lock_cluster "$cluster_name" "$master_dir" || { + echo "$id: Failed to get lock. aborting." + exit 1 + } wpara_opts="$wparallelizer_options $wparallelizer_error_table_opts" $pubtool_debug wparallelizer $quoted_args eval "\$wparallelizer $wpara_opts $quoted_args" @@ -1025,9 +1083,14 @@ *) $maybe_stop_proxy echo "$id: unhandled exit status $?" 1>&2 + publish_unlock_cluster "$cluster_name" "$master_dir" exit 3 ;; esac + echo "$id: removing publish lock for $cluster_name." + publish_unlock_cluster "$cluster_name" "$master_dir" || { + echo "$id: WARNING Failed to remove publish lock for $cluster!." + } # hurrah! test "x$spawned_ssh_agent" = "x1" && kill $SSH_AGENT_PID |