Gabriel Glenn
Gabriel Glenn

Reputation: 1264

ejabberd reload_config command does not add vhost

Using ejabberd in docker with ejabberd/ecs, I need to create vhost dynamically.

  1. I use a script to edit ejabberd.yml to add a vhost entry
  2. Use docker exec -it ejabberd bin/ejabberdctl reload_config to reload the config. According to ejabberd configuration / reload at runtime, it should add/remove vhost
  3. Check vhost with docker exec -it ejabberd bin/ejabberdctl registered_vhosts

registered_vhosts gives me the vhosts before modification. If I docker compose down && docker compose up -d, registered_vhosts gives the added vhost.

It looks like ejabberd or docker are not reporting changes made to ejabberd.yml.

ejabberd.yml after modification:

hosts:
  - a.chat.preprod.example.app
  - b.chat.preprod.example.app
  - c.chat.preprod.example.app
  - d.chat.preprod.example.app
  # <new-line-tag> 
 

docker-compose.yml

version: '3.7'

services:

  main:
    image: ejabberd/ecs
    container_name: ejabberd
    ports:
      - "5222:5222"
      - "5269:5269"
      - "5280:5280" # ACME Well known path
      - "5443:5443"
    volumes:
      - ./ejabberd.yml:/home/ejabberd/conf/ejabberd.yml
      - ./database:/home/ejabberd/database

Edit:

It seems like it have to do with the way I edit the script with sed

sed -i "/<new-line-tag>/i \ \ - $NEW_DOMAIN" ejabberd.yml

But after I change the file with sed, even if I edit it with vi, the changes are not seen.

Upvotes: 0

Views: 35

Answers (1)

Badlop
Badlop

Reputation: 4120

On reload_config, the log show no indication of any change.

Right, this is normal, reload_config just returns success.

registered_vhosts gives me the vhosts before modification

The configuration changes that you make to ejabberd.yml file in the host machine are not immediately available in the hosted machine, so ejabberd doesn't have access to them. Only after a container restart your changes are available.

I can see two alternatives:

  • use a volume driver that automatically updates the mounted volume when it detect changes, like "--volume-driver docker.io/docker/volume-driver"
  • modify the file inside the container

For example:

$ podman exec -it --user root ejabberd vi /home/ejabberd/conf/ejabberd.yml
$ podman exec ejabberd bin/ejabberdctl reload_config
$ podman exec ejabberd bin/ejabberdctl registered_vhosts
localhost
example.com

Upvotes: 1

Related Questions