]> git.cworth.org Git - sup/commitdiff
added a shutdown hook
authorChristopher Warrington <chrisw@rice.edu>
Mon, 10 Nov 2008 10:26:29 +0000 (04:26 -0600)
committerChristopher Warrington <chrisw@rice.edu>
Mon, 10 Nov 2008 10:26:29 +0000 (04:26 -0600)
A shutdown hook has been added. It runs during sup's shutdown,
right before Redwood::finish is called.

bin/sup

diff --git a/bin/sup b/bin/sup
index 124af755d58ab9e04089f240ede3ca20f7061756..ddbad2edc65355b844426c182fea793f2e8c62a9 100644 (file)
--- a/bin/sup
+++ b/bin/sup
@@ -45,6 +45,14 @@ No variables.
 No return value.
 EOS
 
+Redwood::HookManager.register "shutdown", <<EOS 
+Executes when sup is shutting down. May be run when sup is crashing,
+so don\'t do anything too important. Run before the label, contacts,
+and people are saved.
+No variables.
+No return value.
+EOS
+
 if $opts[:list_hooks]
   Redwood::HookManager.print_hooks
   exit
@@ -271,6 +279,8 @@ ensure
     Index.stop_lock_update_thread
   end
 
+  HookManager.run "shutdown"
+
   Redwood::finish
   stop_cursing
   Redwood::log "stopped cursing"