aiidateam / aiida-prerequisites

Docker image that contains all prerequisites allowing to run AiiDA.
2 stars 2 forks source link

Move the mnesia folder of RabbitMQ to `/home/${SYSTEM_USER}`. #17

Closed sphuber closed 4 years ago

sphuber commented 4 years ago

Fixes #16

AiiDA relies on RabbitMQ to persist the tasks that correspond to active processes such that when the daemon and even the machine is rebooted, upon restart the processes can be resumed. RabbitMQ persists this data to disk, in a folder called the "mnesia" folder, which by default for Debian based OS's is located at /var/lib/rabbitmq/mnesia. Since this location is not persisted outside of the container, all tasks corresponding to incompleted AiiDA processes would be lost when the container was stopped.

The solution is to reconfigure RabbitMQ to store the mnesia folder in the /home/${SYSTEM_USER} folder, which is the one volume that is persisted outside of the container. Since this folder is created by the create-system-user.sh initialization script, it had to be moved to be run before the start-rabbitmq.sh script.

Finally, the start-rabbitmq.sh script adds the NODENAME variable to the RabbitMQ configuration file. This is necessary because the mnesia subdirectory contains the hostname, which by default is set to the value of $(hostname -s), which for docker containers, will be a random hexadecimal string. Upon restart, this will be different and so the original mnesia folder with the persisted data will not be found.

The reason RabbitMQ is built this way is through this way it allows to run multiple nodes on a single machine each with isolated mnesia directories. Since in the AiiDA setup we only need and run a single node, we can simply use localhost.