Mattermost, Inc.

Autostart problem ubuntu 18.04

I want to try mattermost on a new installation of ubuntu 18.04 LTS with mysql (mariadb 10.1.44), i did everything from the manual:

https://docs.mattermost.com/install/install-ubuntu-1804.html

I can start the mattermost service with: “service mattermost start” but i can´t get it running on ubuntu autostart. The /lib/systemd/system/mattermost.service is the exact same as in the manual above.

[Unit]
Description=Mattermost
After=network.target
After=mysql.service
Requires=mysql.service

[Service]
Type=notify
ExecStart=/opt/mattermost/bin/mattermost
TimeoutStartSec=3600
Restart=always
RestartSec=10
WorkingDirectory=/opt/mattermost
User=mattermost
Group=mattermost
LimitNOFILE=49152

[Install]
WantedBy=mysql.service

“journalctl -u mattermost.service” says nothing
/var/log/syslog i see no problem there
/opt/mattermost/logs/mattermost.log stays empty after i clear it bevor reboot

After reboot:
root@mattermost-s:~# service mattermost status
● mattermost.service - Mattermost
Loaded: loaded (/lib/systemd/system/mattermost.service; enabled; vendor preset: enabled)
Active: inactive (dead)

I load it “systemctl daemon-reload” and the service is enabled: “systemctl enable mattermost.service”

The DB User has all privileges on the DB, the DB is on the same server.

It looks like it wouldn´t try to start?! I also tried to create a symlink in /etc/systemd/system

Did the manuel and i miss something? Does anyone have any idea what the problem could be?

Hello, @kur

When you mentioned that it does not run with Ubuntu autostart, do you mean that it does not automatically start when the server gets rebooted based on sudo systemctl enable mattermost.service ? Can you share the output of running the same command as you can see from the example I have below?

ahmaddanial@mattermost:~$ sudo systemctl status mattermost.service
● mattermost.service - Mattermost
   Loaded: loaded (/lib/systemd/system/mattermost.service; disabled; vendor preset: enabled)
   Active: active (running) since Wed 2020-05-20 00:34:30 UTC; 1min 57s ago
 Main PID: 16450 (mattermost)
    Tasks: 12
   Memory: 62.2M
      CPU: 2.365s
   CGroup: /system.slice/mattermost.service
           └─16450 /opt/mattermost/bin/mattermost

May 20 00:34:30 mattermost mattermost[16450]: 2020-05-20T00:34:30.896Z        info        app/server.g
May 20 00:34:30 mattermost mattermost[16450]: 2020-05-20T00:34:30.897Z        info        app/server.g
May 20 00:34:30 mattermost mattermost[16450]: 2020-05-20T00:34:30.897Z        info        commands/ser
May 20 00:34:30 mattermost systemd[1]: Started Mattermost.
May 20 00:35:30 mattermost mattermost[16450]: 2020-05-20T00:35:30.813Z        debug        migrations/
May 20 00:35:30 mattermost mattermost[16450]: 2020-05-20T00:35:30.814Z        debug        migrations/
May 20 00:35:30 mattermost mattermost[16450]: 2020-05-20T00:35:30.819Z        debug        jobs/schedu
May 20 00:35:38 mattermost mattermost[16450]: 2020-05-20T00:35:38.944Z        debug        migrations/
May 20 00:35:39 mattermost mattermost[16450]: 2020-05-20T00:35:39.162Z        info        migrations/w
May 20 00:35:39 mattermost mattermost[16450]: 2020-05-20T00:35:39.163Z        debug        jobs/jobs.g
ahmaddanial@mattermost:~$ sudo systemctl enable mattermost.service
Created symlink from /etc/systemd/system/mysql.service.wants/mattermost.service to /lib/systemd/system/mattermost.service.

What happens when you try to start the service again using sudo systemctl restart mattermost.service since the status is showing Active: inactive (dead)?

Hello,

yes i mean it does not automatically start with ubuntu.

It is the same command as shown above “service mattermost status”

root@mattermost-s:/etc/systemd/system/mysql.service.wants# systemctl status mattermost.service
● mattermost.service - Mattermost
Loaded: loaded (/lib/systemd/system/mattermost.service; enabled; vendor preset: enabled)
Active: inactive (dead)

The symlink from /etc/systemd/system/mysql.service.wants/mattermost.service to /lib/systemd/system/mattermost.service is created.

If i use the restart manually: “systemctl restart mattermost.service” than the service is running:

root@mattermost-s:/etc/systemd/system/mysql.service.wants# systemctl status mattermost.service
● mattermost.service - Mattermost
Loaded: loaded (/lib/systemd/system/mattermost.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2020-05-20 07:11:24 CEST; 2s ago
Main PID: 2517 (mattermost)
Tasks: 16 (limit: 2322)
CGroup: /system.slice/mattermost.service
├─2517 /opt/mattermost/bin/mattermost
└─2548 plugins/com.mattermost.nps/server/dist/plugin-linux-amd64
May 20 07:11:24 mattermost-s mattermost[2517]: {“level”:“info”,“ts”:1589951484.7056549,“caller”:“app/server.go:267”,“msg”:“Printing current working”,“directory”:"/opt/mattermost"}
May 20 07:11:24 mattermost-s mattermost[2517]: {“level”:“info”,“ts”:1589951484.7057877,“caller”:“app/server.go:268”,“msg”:“Loaded config”,“source”:“file:///opt/mattermost/config/config.json”}
May 20 07:11:24 mattermost-s mattermost[2517]: {“level”:“info”,“ts”:1589951484.7337282,“caller”:“sqlstore/post_store.go:1518”,“msg”:“Post.Message has size restrictions”,“max_characters”:16383,“max_bytes”:6553
May 20 07:11:24 mattermost-s mattermost[2517]: {“level”:“info”,“ts”:1589951484.8053088,“caller”:“jobs/workers.go:68”,“msg”:“Starting workers”}
May 20 07:11:24 mattermost-s mattermost[2517]: {“level”:“info”,“ts”:1589951484.8134096,“caller”:“app/web_hub.go:75”,“msg”:“Starting websocket hubs”,“number_of_hubs”:2}
May 20 07:11:24 mattermost-s mattermost[2517]: {“level”:“info”,“ts”:1589951484.82053,“caller”:“jobs/schedulers.go:74”,“msg”:“Starting schedulers.”}
May 20 07:11:24 mattermost-s mattermost[2517]: {“level”:“info”,“ts”:1589951484.8352268,“caller”:“app/server.go:506”,“msg”:“Starting Server…”}
May 20 07:11:24 mattermost-s mattermost[2517]: {“level”:“info”,“ts”:1589951484.8356643,“caller”:“app/server.go:575”,“msg”:“Server is listening on [::]:8065”,“address”:"[::]:8065"}
May 20 07:11:24 mattermost-s mattermost[2517]: {“level”:“info”,“ts”:1589951484.8358457,“caller”:“commands/server.go:105”,“msg”:“Sending systemd READY notification.”}
May 20 07:11:24 mattermost-s systemd[1]: Started Mattermost.

Hi, @kur

Now that the systemctl status mattermost.service shows that the service is running, did you try run sudo systemctl enable mattermost.service again and reboot the server to confirm that the Mattermost Server is not started automatically after the system is up again?

I tried that bevor, but did it again now. Same as bevor, i enabled it and then reboot the server:

systemctl enable mattermost.service
reboot now

root@mattermost-s:~# systemctl status mattermost.service
● mattermost.service - Mattermost
Loaded: loaded (/lib/systemd/system/mattermost.service; enabled; vendor preset: enabled)
Active: inactive (dead)

Hi, @kur

Did you install your MySQL in the same server or dedicated server instead? If yes, did you check on the section in the installation article in step 10b?

If you have installed MySQL or PostgreSQL on a dedicated server, then you need to

  • remove After=postgresql.service and Requires=postgresql.service or After=mysql.service and Requires=mysql.service lines in the [Unit] section, and
  • replace the WantedBy=postgresql.service or WantedBy=mysql.service line in the [Install] section with WantedBy=multi-user.target

or the Mattermost service will not start.

Just want to make sure that we cover all the points there.

As mentioned in the first post, mysql/database is on the same server as mattermost. Only 1 ubunutu server for everything.