← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~jtv/maas/fast-stop-db into lp:maas

 

Jeroen T. Vermeulen has proposed merging lp:~jtv/maas/fast-stop-db into lp:maas.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~jtv/maas/fast-stop-db/+merge/93379

Shutting down a dev DB cluster (including as part of “make distclean”) currently waits for all clients to go away, and for the cluster to shut down cleanly.  There's really no point; these disposable clusters and more often than not, when we want them stopped, it's because we want to wipe them off the face of the virtual world anyway.

So don't wait for confirmation.  Also, print some usage help if the user doesn't get the maasdb incantation right.
-- 
https://code.launchpad.net/~jtv/maas/fast-stop-db/+merge/93379
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jtv/maas/fast-stop-db into lp:maas.
=== modified file 'utilities/maasdb'
--- utilities/maasdb	2012-01-20 12:41:30 +0000
+++ utilities/maasdb	2012-02-16 11:23:21 +0000
@@ -91,7 +91,7 @@
 
     if test -f "$DATADIR/postmaster.pid"
     then
-        $PGCTL stop -D "$DATADIR"
+        $PGCTL stop -W -m fast -D "$DATADIR"
     fi
 }
 
@@ -150,11 +150,40 @@
 }
 
 
+usage() {
+    cat <<EOF >&2
+Usage: maasdb <command> <cluster-path>
+
+Where <command> is one of:
+  start
+  stop
+  query
+  shell
+  delete-cluster
+
+And <cluster-path> is the path to the MaaS development database cluster,
+typically "./db"
+EOF
+}
+
+
+unknown_command() {
+    echo >&2 "** Unknown command: $1 **"
+    echo
+    usage
+    exit 1
+}
+
+
 main() {
     local COMMAND DATADIR
     COMMAND="$1"
     DATADIR="$2"
-    shift 2
+    if ! shift
+    then
+        usage
+        exit 1
+    fi
 
     case "$COMMAND" in
         start) maasdb_init_db "$DATADIR" "$@" ;;
@@ -162,6 +191,7 @@
         query) maasdb_query "$DATADIR" "$@" ;;
         shell) maasdb_shell "$DATADIR" "$@" ;;
         delete-cluster) maasdb_delete_cluster "$DATADIR" "$@" ;;
+        *) unknown_command "$COMMAND" ;;
     esac
 }