Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(721)

Unified Diff: scripts/slave/recipe_modules/chromium_android/resources/shutdown_device_temp_monitor.py

Issue 1308173006: Create daemon to monitor android device temperatures (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: scripts/slave/recipe_modules/chromium_android/resources/shutdown_device_temp_monitor.py
diff --git a/scripts/slave/recipe_modules/chromium_android/resources/shutdown_device_temp_monitor.py b/scripts/slave/recipe_modules/chromium_android/resources/shutdown_device_temp_monitor.py
new file mode 100755
index 0000000000000000000000000000000000000000..417c9f4e8b5ecba4557c94b29995a6dc40651492
--- /dev/null
+++ b/scripts/slave/recipe_modules/chromium_android/resources/shutdown_device_temp_monitor.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+
+"""
+Shutdown the device_temp_monitor process launched
+by spawn_device_temp_monitor.py by reading its pid in the file pid_file_path.
+"""
+
+import logging
+import os
+import signal
+import sys
+
+def main(pid_file_path='/tmp/device_monitor_pid'):
luqui 2015/09/03 01:10:41 pidfiles usually end in .pid, rather than _pid.
jbudorick 2015/09/03 17:37:31 I'd use argparse for command-line arguments to a s
+
+ try:
+ with open(pid_file_path) as pid_file:
+ monitor_pid = int(pid_file.readline())
+
+ logging.info('Sending SIGTERM to %d', monitor_pid)
+ os.kill(monitor_pid, signal.SIGTERM)
+ os.remove(pid_file_path)
luqui 2015/09/03 01:10:41 I think it should clean up its own pidfile with a
+
+ except (IOError, OSError):
+ logging.exception('Error terminating device monitor')
+
+if __name__ == '__main__':
+ sys.exit(main(*sys.argv[1:]))

Powered by Google App Engine
This is Rietveld 408576698