mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-22 21:38:11 -05:00
Tweak wrap-job to support queue consumer naming conventions.
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user