How to prevent Pydio Cells to gobble up whatever ports it wants... [partial workaround included]

Hi all,

This is supposed to be a simple question — the kind that eventually ought to find its way into the Knowledge Base!

I need to know what ports Pydio Cells opens, and how to configure each and every one individually — because otherwise there will be conflicts with other running applications (even if such ports are just internal).

Many of those ports can be set on ~/.config/pydio/cells/pydio.json, e.g.

  "frontend": {
    "plugin": {
      "editor.libreoffice": {
        "LIBREOFFICE_HOST": "localhost",
        "LIBREOFFICE_PORT": "9980",
        "LIBREOFFICE_SSL": true
      }
    },
[...]
  "ports": {
    "nats": 4222,
    "pydio.gateway.rest": 34761
  },
[...]

There are a few more, for cells-client and cells-sync, for instance.

Other configurations, for some obscure reason, prefer to use ~/pydio.json instead:

"defaults": {
[...]
  "sites": [
      {
        "Binds": [
          "10.169.169.1:8443"
        ],
[...]
  "services": {
[...]
    "pydio.grpc.data.objects.local1": {
      "ApiKey": "<REDACTED>",
      "ApiSecret": "<REDACTED>",
      "LocalFolder": "<REDACTED>",
      "Name": "local1",
      "RunningPort": 43841
    },

But others get sadly completely ignored (these were added by me):

  "services": {
[...]
    "pydio.grpc.broker": {
      "port": "33160"
    },
    "pydio.grpc.discovery": {
      "port": "33162"
    },
    "pydio.grpc.registry": {
      "port": "33161"
    },

Most notably, Pydio Cells will bind to port 8001 and 8002 no matter what is configured. And that’s a bummer, since I need the port range 8000-9200 to be free — these have to be used for an entirely different service running on the same server, and I cannot change them.

The error on the logs, as expected, is:

************************************************************
✗ Error while starting discovery server:
✗ server.Start grpc: listen tcp 0.0.0.0:8002: bind: address already in use
✗ FATAL : shutting down now!
************************************************************

Note that I was expecting to see listen tcp 10.169.169.1:XXXX on my particular configuration (and hopefully never port 8002!)

… but unfortunately, there was nothing that I managed to do that would change that port to something that was safe (i.e. not already bound). Also, starting the other application first (it’s actually a series of them, also working as a whole, and exposing that well-known port range to the exterior world…) would just get Pydio Cells eternally waiting for ports 8001-2 to be released…


My current workaround is to ‘force’ the ports via the command line:

./cells start --grpc_port 33161 --grpc_discovery_port 33162 --config "file:///<a very long absolute path>/pydio.json"

Granted, this will just work for a subset of the ports — currently shown with ./cells start --help (as I’ve discovered by pure chance!):

  --grpc_discovery_port string   Default discovery gRPC server port (registry, broker, config, and log services). (default "8002")
  --grpc_port string             Default gRPC server port (all gRPC services, except discovery ones) (default "8001")
  --healthcheck int              Healthcheck port number

In my case, since I just wished to handle ports 8001 and 8002, this solution worked well for me; however, I can imagine that changing other ports would be useful as well.

Also, I wonder if any of those three can be placed inside a configuration file? If so, where? And how? Using the ‘obvious’ places, as described above, did not work.

(I know, I could try to search on the source code for an answer; and, in fact, I did a bit of searching and digging into the code in search of the bits that handle the ports, but the code for Pydio Cells is not exactly small — there are tens of thousands of lines, and while I found some scattered references to some ports (such as those read from the command line), I’m not familiar enough with the overall codebase in order to figure out where to look for…)

Thanks in advance for any insights! As said, speaking strictly for myself, I can live with this workaround, but others might require a bit more control over all ports, not just a selected few…

You’re on the right track.
Every flag can be passed as an ENVIRONMENT variable as a CELLS_[UPPER_CASE] variable. So if you are using systemd, you can set up these with Environment lines and CELLS_GRPC_DISCOVERY_PORT, CELLS_GRPC_PORT, etc…