Problem
After migrating your Mattermost deployment from MySQL to PostgreSQL, you may encounter an issue where stopping the MySQL service causes the Mattermost application to shut down unexpectedly. This behavior persists even though the PostgreSQL migration appears successful and the application is configured to use PostgreSQL.
Cause
This issue is typically caused by the Mattermost systemd service configuration still referencing the MySQL service as a dependency. Specifically, the BindsTo
and After
directives in the systemd unit file are set to mysql.service
. As a result, stopping MySQL also stops the Mattermost service.
Solution
To resolve the issue, you’ll need to update the systemd service file to reference postgresql.service
instead of mysql.service
.
-
Locate the Mattermost systemd service file
This is usually located at:/lib/systemd/system/mattermost.service
or
/etc/systemd/system/mattermost.service
-
Open the file and review the contents.
It may look something like this:[Unit] Description=Mattermost After=network.target After=mysql.service BindsTo=mysql.service [Service] Type=notify ExecStart=/opt/mattermost/bin/mattermost TimeoutStartSec=3600 KillMode=mixed Restart=always RestartSec=10 WorkingDirectory=/opt/mattermost User=mattermost Group=mattermost LimitNOFILE=49152 [Install] WantedBy=mysql.service
-
Update all instances of
mysql.service
topostgresql.service
:[Unit] Description=Mattermost After=network.target After=postgresql.service BindsTo=postgresql.service [Service] Type=notify ExecStart=/opt/mattermost/bin/mattermost TimeoutStartSec=3600 KillMode=mixed Restart=always RestartSec=10 WorkingDirectory=/opt/mattermost User=mattermost Group=mattermost LimitNOFILE=49152 [Install] WantedBy=multi-user.target
-
After updating the service configuration, make sure to restart the Mattermost service to apply the changes.
Comments
Article is closed for comments.