Repository: zulip/zulip

Issue:
Potential bug with Supervisor zulip.conf
I just merged commits made within the past few days.  On my live server, I'm now seeing repeated errors like this:

```
manage.py process_queue: error: unrecognized arguments: missedmessage_mobile_notifications
usage: manage.py process_queue [-h] [--version] [-v {0,1,2,3}]
                               [--settings SETTINGS] [--pythonpath PYTHONPATH]
                               [--traceback] [--no-color]
                               [--queue_name <queue name>]
                               [--worker_num [<worker number>]] [--all]
```

I'm light as far as configuration / DevOps, but I believe this is because `process_queue` is being executed by:  `/puppet/zulip/files/supervisor/conf.d/zulip.conf` and the contained commands not using the  `--` characters before the arguments?

[Example here](https://github.com/zulip/zulip/blob/master/puppet/zulip/files/supervisor/conf.d/zulip.conf#L102)



Discussion:
yes, that's exactly right.  We need to revert the part of the process_queue.py refactoring in cd2348e9aec36d7f26475fa7d966d06588dbeb75 that desupported that way of specifying arguments.

Thanks for reporting this @danshev!  Ultimately this is a failure of our "production" test suite that it didn't catch this.

Absolutely -- glad it was of help!

#597 should fix this; if you're up for testing this @danshev, I'd definitely appreciate it!

Certainly; will do it right now.

I'm seeing:

```
2016-03-27 18:33:14,640 INFO     Worker 0 connecting to queue message_sender
Traceback (most recent call last):
  File "/home/zulip/deployments/current/manage.py", line 25, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/usr/lib/python2.7/dist-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python2.7/dist-packages/django/core/management/base.py", line 393, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/lib/python2.7/dist-packages/django/core/management/base.py", line 444, in execute
    output = self.handle(*args, **options)
  File "/home/zulip/deployments/2016-03-27-22-31-02/zerver/management/commands/process_queue.py", line 49, in handle
    worker.start()
  File "/home/zulip/deployments/2016-03-27-22-31-02/zerver/worker/queue_processors.py", line 92, in start
    self.q.register_json_consumer(self.queue_name, self.consume_wrapper)
AttributeError: 'NoneType' object has no attribute 'register_json_consumer'
```

Ok will look tonight

-Tim Abbott (mobile)
On Mar 27, 2016 3:34 PM, "Dan Shevenell" notifications@github.com wrote:

> I'm seeing:
> 
> 2016-03-27 18:33:14,640 INFO     Worker 0 connecting to queue message_sender
> Traceback (most recent call last):
>   File "/home/zulip/deployments/current/manage.py", line 25, in <module>
>     execute_from_command_line(sys.argv)
>   File "/usr/lib/python2.7/dist-packages/django/core/management/**init**.py", line 338, in execute_from_command_line
>     utility.execute()
>   File "/usr/lib/python2.7/dist-packages/django/core/management/**init**.py", line 330, in execute
>     self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "/usr/lib/python2.7/dist-packages/django/core/management/base.py", line 393, in run_from_argv
>     self.execute(_args, *_cmd_options)
>   File "/usr/lib/python2.7/dist-packages/django/core/management/base.py", line 444, in execute
>     output = self.handle(_args, *_options)
>   File "/home/zulip/deployments/2016-03-27-22-31-02/zerver/management/commands/process_queue.py", line 49, in handle
>     worker.start()
>   File "/home/zulip/deployments/2016-03-27-22-31-02/zerver/worker/queue_processors.py", line 92, in start
>     self.q.register_json_consumer(self.queue_name, self.consume_wrapper)
> AttributeError: 'NoneType' object has no attribute 'register_json_consumer'
> 
> —
> You are receiving this because you commented.
> Reply to this email directly or view it on GitHub
> https://github.com/zulip/zulip/issues/586#issuecomment-202162786


Resolving patch:
diff --git a/zerver/management/commands/process_queue.py b/zerver/management/commands/process_queue.py
--- a/zerver/management/commands/process_queue.py
+++ b/zerver/management/commands/process_queue.py
@@ -38,6 +38,7 @@ def handle(self, *args, **options):
 
             logger.info("Worker %d connecting to queue %s" % (worker_num, queue_name))
             worker = get_worker(queue_name)
+            worker.setup()
 
             def signal_handler(signal, frame):
                 logger.info("Worker %d disconnecting from queue %s" % (worker_num, queue_name))


Test patch: