diff mbox

[Branch,~linaro-validation/lava-dispatcher/trunk] Rev 238: add support for optionally including a job id in the process name as seen by top (Zygmunt)

Message ID 20120302031410.2848.14227.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

Michael-Doyle Hudson March 2, 2012, 3:14 a.m. UTC
Merge authors:
  Zygmunt Krynicki (zkrynicki)
Related merge proposals:
  https://code.launchpad.net/~zkrynicki/lava-dispatcher/fix-944088/+merge/95414
  proposed by: Zygmunt Krynicki (zkrynicki)
------------------------------------------------------------
revno: 238 [merge]
committer: Michael Hudson-Doyle <michael.hudson@linaro.org>
branch nick: trunk
timestamp: Fri 2012-03-02 16:10:00 +1300
message:
  add support for optionally including a job id in the process name as seen by top (Zygmunt)
modified:
  lava-dispatch
  lava_dispatcher/job.py


--
lp:lava-dispatcher
https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk

You are subscribed to branch lp:lava-dispatcher.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'lava-dispatch'
--- lava-dispatch	2011-12-01 15:12:02 +0000
+++ lava-dispatch	2012-03-01 17:10:04 +0000
@@ -24,7 +24,7 @@ 
 import sys
 import logging.config
 
-from linaro_json.schema import ValidationError
+from json_schema_validator.errors import ValidationError
 
 from lava_dispatcher.job import LavaTestJob
 from lava_dispatcher.config import get_config
@@ -39,6 +39,9 @@ 
 parser.add_option(
     "--validate", action='store_true',
     help="Just validate the job file, do not execute any steps.")
+parser.add_option(
+    "--job-id", action='store', default=None,
+    help="Set the scheduler job identifier. This alters process name for easier debugging")
 
 (options, args) = parser.parse_args()
 
@@ -61,6 +64,16 @@ 
 DATEFMT= '%Y-%m-%d %I:%M:%S %p'
 logging.basicConfig(format=FORMAT,datefmt=DATEFMT)
 
+# Set process id if job-id was passed to dispatcher
+if options.job_id:
+    try:
+        from setproctitle import getproctitle, setproctitle
+    except ImportError:
+        logging.warning("Unable to set import 'setproctitle', process name cannot be changed")
+    else:
+        setproctitle("%s [job: %s]" % (getproctitle(), options.job_id))
+
+
 config = get_config("lava-dispatcher", options.config_dir)
 logging_level = config.get("LOGGING_LEVEL")
 logging.root.setLevel(int(logging_level))

=== modified file 'lava_dispatcher/job.py'
--- lava_dispatcher/job.py	2012-02-15 02:43:21 +0000
+++ lava_dispatcher/job.py	2012-03-01 16:17:19 +0000
@@ -23,7 +23,8 @@ 
 import pexpect
 import traceback
 
-from linaro_json.schema import Schema, Validator
+from json_schema_validator.schema import Schema
+from json_schema_validator.validator import Validator
 
 from lava_dispatcher.actions import get_all_cmds
 from lava_dispatcher.client.base import CriticalError, GeneralError