Permalink
Browse files

Tweak wrap-job to support queue consumer naming conventions.

  • Loading branch information...
1 parent 5c80560 commit 533e695d55fc98732a12ddbcf371fadc02dc8ca1 @spladug spladug committed May 31, 2012
Showing with 10 additions and 0 deletions.
  1. +10 −0 scripts/wrap-job
View
@@ -32,6 +32,9 @@ import syslog
import subprocess
+CONSUMER_PREFIX = "reddit-consumer-"
+
+
# drop permissions
user = os.environ.get("REDDIT_USER", "reddit")
group = os.environ.get("REDDIT_GROUP", user)
@@ -48,6 +51,13 @@ os.chdir(r2_root)
# configure syslog
job_name = os.environ.get("UPSTART_JOB", "-".join(sys.argv[1:]))
+if job_name.startswith(CONSUMER_PREFIX):
+ # consumers are a bit different from crons, while crons want an
+ # ident of reddit-job-JOBNAME, we want consumers to have an ident
+ # of CONSUMERNAME_INSTANCE
+ job_name = (job_name[len(CONSUMER_PREFIX):] +
+ "_" +
+ os.environ.get("UPSTART_INSTANCE", ""))
facility = getattr(syslog, "LOG_" + os.environ.get("REDDIT_LOG_FACILITY", "CRON"))
syslog.openlog(ident=job_name, facility=facility)

0 comments on commit 533e695

Please sign in to comment.