tiagocoutinho/multivisor

Unable to connect multivisor to supervisor protected by password

Closed this issue · 11 comments

Hi,

If I try to use credentials to protected supervisor, doesn't works.

Example:
I try with multivisor.conf:

[supervisor:lid001]
url=SERVERNAME:PORT
username=XXXX
password=XXXX

And with multivisor.conf:

[supervisor:lid001]
url=XXXX:XXXX@SERVERNAME:PORT

Doesn't works.

You can see the output logs here:

INFO 2019-05-06 12:15:41,264 root: Start accepting requests
INFO 2019-05-06 12:15:41,272 multivisor.lid001: (re)initializing...
INFO 2019-05-06 12:15:56,276 multivisor.lid001: Lost remote

Hello @anthosz!
Right now you can turn on authentication in multivisor, so for example in multivisor.conf:

[supervisor:lid001]
url=localhost:9012

[global]
username=test
password=test

You also need to set MULTIVISOR_SECRET_KEY environmental variable, if you don't then you'll get an error.

I am not sure what exactly are you trying to achieve by specifying username and password in supervisor block. Multivisor is not using http server of supervisor, it is using it's own RPC interface, which you specify this way in supervisord.conf:

[rpcinterface:multivisor]
supervisor.rpcinterface_factory = multivisor.rpc:make_rpc_interface
bind=*:9002

And then in multivisor.conf

[supervisor:lid001]
# no host is given: defaults to lid001
url=:9002

I mean:

I have multiple supervisord instance:

  • server1:9001
  • server2:9001
  • server3:9001

You can see the default conf here (bind unrecognized):

[inet_http_server]
port = :9001
username=XXXX
password=XXXX
[rpcinterface:supervisor]
supervisor.rpcinterface_factory=supervisor.rpcinterface:make_main_rpcinterface

My goal is to user multivisor to connect to each existing supervisor instance:

So in multivisor of server1:

[supervisor:s1]
url=:9001
username=XXXX (cred of server1)
password=XXXX

[supervisor:s2]
url=:9001
username=XXXX (cred of server2)
password=XXXX

[supervisor:s3]
url=:9001
username=XXXX (cred of server3)
password=XXXX

Ok, so if I understand well, I need to deploy multivisor on each server behind supervisord? Multivisor cannot directly connect the http port of supervisord? :/

[rpcinterface:supervisor]
supervisor.rpcinterface_factory=supervisor.rpcinterface:make_main_rpcinterface

This is supervisor RPC interface, you need to also setup the one provided by multivisor:

[rpcinterface:multivisor]
supervisor.rpcinterface_factory = multivisor.rpc:make_rpc_interface
bind=*:9002

In order to do that, you must have multivisor package installed on node with running supervisord.

Multivisor cannot directly connect the http port of supervisord? :/

No, multivisor is using rpc interface instead of http, it allows for more flexibility.

And it's not possible (or maybe in the roadmap) to use only supervisord http server?

To avoid to add a new service (nodejs) on each node behind supervisor..

Thx!

Nodejs? You don't need to run any npm commands on supervisor nodes. You only need multivisor package installed by pip on those.
Currently there is a pull request to split dependencies, so basically less python packages will be required to run only multivisor RPC on supervisor node. #27

The following should work:

# multivisor.conf

[supervisor:<name>]
url=<supervisor host name/IP>:<supervisor zerorpc port>

and

# supervisor.conf

# usual supervisor config (including standard RPC if you want)
# ...

[rpcinterface:multivisor]
supervisor.rpcinterface_factory = multivisor.rpc:make_rpc_interface
bind=*:<supervisor zerorpc port>

To clarify

  • multivisor implements it's own supervisor RPC interface. Unlike the standard supervisor RPC interface, it doesn't support authentication so in multivisor.conf you shouldn't configure any credentials since it multivisor doesn't use them
  • multivisor RPC is very similar to supervisor RPC. Instead of xmlrpc it uses zerorpc. The most important reason is to be able to stream events to multivisor web server and make the web interface reactive
  • until the several multivisor components are split (see #27) you have to install the complete multivisor and its dependencies on each machine that runs supervisor and on the machine that runs the multivisor web server. For you it just means a few more megabytes of python and javascript files in the installation directory. Nodejs is not in the list of dependencies

I realized I repeated most of what @guy881 explained before in other words. Sorry for that. I hope I didn't introduce too much noise

No, no, it was a good idea to sum things up. Maybe we could also improve README based on what you wrote. ;)

Dear @tiagocoutinho @guy881,

Thank you for the clarification. It's more clear now :)

Last question for information: so to use [rpcinterface:multivisor] in supervisor.conf, we need supervisord via your repository (it's the last version of supervisord with a plugin or a fork?). We cannot just use supervisord ootb and add like a plugin?

I don't know if I am clear. Tell me if not.

Best regards,

Hello @anthosz,
As you can read in the README:

Make sure multivisor is installed in the same environment as the one supervisor(s) is(are) running

Supervisor is specified as a dependency in multivisor requirements. So it will be installed from pip during the installation of multivisor. You can check the version of supervisor in your environment by using supervisord -v. You can also check the path to supervisord by typing which supervisord.

We cannot just use supervisord ootb and add like a plugin

You cannot use supervisor which would be outside your python environment with multivisor installed (for example the one installed by distro package). The reason for this is simple, if you define multivisor rpc interface in your supervisor config, supervisor must recognize multivisor module to use make_rpc_interface function from rpc module. Hope it will make it clear. ;)

[rpcinterface:multivisor]
supervisor.rpcinterface_factory = multivisor.rpc:make_rpc_interface
bind=*:9002