Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Tweak wrap-job to support queue consumer naming conventions.

  • Loading branch information...
commit 533e695d55fc98732a12ddbcf371fadc02dc8ca1 1 parent 5c80560
Neil Williams spladug authored
Showing with 10 additions and 0 deletions.
  1. +10 −0 scripts/wrap-job
10 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)
Please sign in to comment.
Something went wrong with that request. Please try again.