Merge "Support stack on Geard embedded server"
diff --git a/doc/source/zuul.rst b/doc/source/zuul.rst
index 0d63512..2883253 100644
--- a/doc/source/zuul.rst
+++ b/doc/source/zuul.rst
@@ -1050,9 +1050,11 @@
   ./tools/zuul-changes.py --review-host=review.openstack.org \
       http://zuul.openstack.org/ check 'recheck'
 
-If you send a SIGUSR2 to the zuul-server process, Zuul will dump a stack
-trace for each running thread into its debug log. This is useful for
-tracking down deadlock or otherwise slow threads.
+If you send a SIGUSR2 to the zuul-server process, or the forked process
+that runs the Gearman daemon, Zuul will dump a stack trace for each
+running thread into its debug log. It is written under the log bucket
+``zuul.stack_dump``.  This is useful for tracking down deadlock or
+otherwise slow threads.
 
 When `yappi <https://code.google.com/p/yappi/>`_ (Yet Another Python
 Profiler) is available, additional functions' and threads' stats are
diff --git a/zuul/cmd/server.py b/zuul/cmd/server.py
index 9da300e..832eae4 100755
--- a/zuul/cmd/server.py
+++ b/zuul/cmd/server.py
@@ -150,6 +150,7 @@
         import zuul.webapp
         import zuul.rpclistener
 
+        signal.signal(signal.SIGUSR2, zuul.cmd.stack_dump_handler)
         if (self.config.has_option('gearman_server', 'start') and
             self.config.getboolean('gearman_server', 'start')):
             self.start_gear_server()
@@ -204,7 +205,6 @@
 
         signal.signal(signal.SIGHUP, self.reconfigure_handler)
         signal.signal(signal.SIGUSR1, self.exit_handler)
-        signal.signal(signal.SIGUSR2, zuul.cmd.stack_dump_handler)
         signal.signal(signal.SIGTERM, self.term_handler)
         while True:
             try: