Merge "Add command_socket setting to executor section" into feature/zuulv3
diff --git a/doc/source/admin/components.rst b/doc/source/admin/components.rst
index d988351..126e4e2 100644
--- a/doc/source/admin/components.rst
+++ b/doc/source/admin/components.rst
@@ -397,6 +397,11 @@
 
 .. attr:: executor
 
+   .. attr:: command_socket
+      :default: /var/lib/zuul/executor.socket
+
+      Path to command socket file for the executor process.
+
    .. attr:: finger_port
       :default: 79
 
diff --git a/tests/base.py b/tests/base.py
index 4599942..931771f 100755
--- a/tests/base.py
+++ b/tests/base.py
@@ -2070,6 +2070,9 @@
         self.config.set('executor', 'git_dir', self.executor_src_root)
         self.config.set('executor', 'private_key_file', self.private_key_file)
         self.config.set('executor', 'state_dir', self.executor_state_root)
+        self.config.set(
+            'executor', 'command_socket',
+            os.path.join(self.test_root, 'executor.socket'))
 
         self.statsd = FakeStatsd()
         if self.config.has_section('statsd'):
diff --git a/zuul/cmd/executor.py b/zuul/cmd/executor.py
index aef8c95..24bda93 100755
--- a/zuul/cmd/executor.py
+++ b/zuul/cmd/executor.py
@@ -53,11 +53,11 @@
             self.args.nodaemon = True
 
     def send_command(self, cmd):
-        state_dir = get_default(self.config, 'executor', 'state_dir',
-                                '/var/lib/zuul', expand_user=True)
-        path = os.path.join(state_dir, 'executor.socket')
+        command_socket = get_default(
+            self.config, 'executor', 'command_socket',
+            '/var/lib/zuul/executor.socket')
         s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
-        s.connect(path)
+        s.connect(command_socket)
         cmd = '%s\n' % cmd
         s.sendall(cmd.encode('utf8'))
 
diff --git a/zuul/executor/server.py b/zuul/executor/server.py
index 83fdc3c..5f0f2b7 100644
--- a/zuul/executor/server.py
+++ b/zuul/executor/server.py
@@ -1608,10 +1608,13 @@
         self.merger = self._getMerger(self.merge_root)
         self.update_queue = DeduplicateQueue()
 
+        command_socket = get_default(
+            self.config, 'executor', 'command_socket',
+            '/var/lib/zuul/executor.socket')
+        self.command_socket = commandsocket.CommandSocket(command_socket)
+
         state_dir = get_default(self.config, 'executor', 'state_dir',
                                 '/var/lib/zuul', expand_user=True)
-        path = os.path.join(state_dir, 'executor.socket')
-        self.command_socket = commandsocket.CommandSocket(path)
         ansible_dir = os.path.join(state_dir, 'ansible')
         self.ansible_dir = ansible_dir
         if os.path.exists(ansible_dir):