Skip to content

Commit 356827b

Browse files
committed
Merge pull request #149 from ydaniv/mgmt-cmd-opt-pid
Added pid option that mimics the same option on RQ's cli
2 parents 07674a1 + 4b15d5b commit 356827b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

django_rq/management/commands/rqworker.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import importlib
23
import logging
34
from optparse import make_option
@@ -69,10 +70,23 @@ class Command(BaseCommand):
6970
default=420,
7071
help='Default worker timeout to be used'
7172
),
73+
make_option(
74+
'--pid',
75+
action='store',
76+
dest='pid',
77+
default=None,
78+
help='PID file to write the worker`s pid into'
79+
),
7280
)
7381
args = '<queue queue ...>'
7482

7583
def handle(self, *args, **options):
84+
85+
pid = options.get('pid')
86+
if pid:
87+
with open(os.path.expanduser(pid), "w") as fp:
88+
fp.write(str(os.getpid()))
89+
7690
try:
7791
# Instantiate a worker
7892
worker_class = import_attribute(options.get('worker_class', 'rq.Worker'))

0 commit comments

Comments
 (0)