[autotest] Add a log socket server for RPM controller to write log from multiple processes

set_power_state call is executed in a new process. logging to a single file
from multiple process may cause the process to hang. A reliable solution is to
create a SocketHandler to log to a TCP server. The source code is from python
documentation:
https://docs.python.org/2/howto/logging-cookbook.html#network-logging

BUG=chromium:243567
DEPLOY=rpm
TEST=unittest, local test script
modify frontend_addr in rpm_config.ini to localhost
Add a dummy set_power_state call in rpm_controller.py to wait indefinitely.
Also add some logging call in it.
Run frontend_server and rpm_dispatcher in localhost
Run a test script that calls 500 duts, e.g., chromeos1-rack#-host 1, #=1-500
Wait for all calls to time out, check ps to make sure only 2 rpm_dispatcher
processes are running at the end (the additional one is for the TCP server
collecting log).

Change-Id: I594cb55c9a2230ac34c90eca7e9de355c21a0dca
Reviewed-on: https://chromium-review.googlesource.com/194432
Tested-by: Dan Shi <dshi@chromium.org>
Reviewed-by: Alex Miller <milleral@chromium.org>
Commit-Queue: Dan Shi <dshi@chromium.org>
diff --git a/site_utils/rpm_control_system/rpm_dispatcher.py b/site_utils/rpm_control_system/rpm_dispatcher.py
index 22671a1..a68c82e 100755
--- a/site_utils/rpm_control_system/rpm_dispatcher.py
+++ b/site_utils/rpm_control_system/rpm_dispatcher.py
@@ -284,7 +284,10 @@
     if len(sys.argv) > 1:
       print 'Usage: ./%s, no arguments available.' % sys.argv[0]
       sys.exit(1)
-    rpm_logging_config.set_up_logging(LOG_FILENAME_FORMAT)
+    rpm_logging_config.start_log_server(LOG_FILENAME_FORMAT)
+    rpm_logging_config.set_up_logging(log_filename_format=LOG_FILENAME_FORMAT,
+                                      use_log_server=True)
+
     # Get the local ip _address and set the server to utilize it.
     address = socket.gethostbyname(socket.gethostname())
     server, port = launch_server_on_unused_port()