Mattermost, Inc.

[SOLVED] Start MM via systemd ubuntu 16.04

Hi There,

Today I started the installation of mattermost on Ubuntu 16.04, since Ubuntu 16.04 is using systemd instead of init I need to create a script that can start up MM on boot.

This is what I got so far:

[Unit]
Description=Starting Mattermost -:slight_smile:

[Service]
Type=oneshot
ExecStart=/opt/mattermost/bin/platform
ExecStop=/bin/kill -9 $MAINPID

[Install]
WantedBy=multi-user.target

When running “systemctl start mattermost.service” I get the following output:

mattermost.service - Starting Mattermost -:slight_smile:
Loaded: loaded (/lib/systemd/system/mattermost.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Wed 2016-05-18 12:24:55 UTC; 12s ago
Process: 8785 ExecStart=/opt/mattermost/bin/platform (code=exited, status=2)
Main PID: 8785 (code=exited, status=2)

May 18 12:24:55 bergpolder platform[8785]: github.com/mattermost/platform/utils.InitTranslationsWithDir(0xd891f8, 0x4)
May 18 12:24:55 bergpolder platform[8785]: /var/lib/jenkins/jobs/mattermost-platform-release/workspace/src/github.com/mattermost/platform/utils/i18n.go:33 +0x2ee
May 18 12:24:55 bergpolder platform[8785]: github.com/mattermost/platform/utils.InitTranslations()
May 18 12:24:55 bergpolder platform[8785]: /var/lib/jenkins/jobs/mattermost-platform-release/workspace/src/github.com/mattermost/platform/utils/i18n.go:19 +0x2c
May 18 12:24:55 bergpolder platform[8785]: main.main()
May 18 12:24:55 bergpolder platform[8785]: /var/lib/jenkins/jobs/mattermost-platform-release/workspace/src/github.com/mattermost/platform/mattermost.go:77 +0x2c
May 18 12:24:55 bergpolder systemd[1]: mattermost.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
May 18 12:24:55 bergpolder systemd[1]: Failed to start Starting Mattermost -:).
May 18 12:24:55 bergpolder systemd[1]: mattermost.service: Unit entered failed state.
May 18 12:24:55 bergpolder systemd[1]: mattermost.service: Failed with result ‘exit-code’.

How can I solve this?

Cheers!

Check logs/mattermost.log for problems. Looks like platform started but then died immediately.

My previous install used to start mm with an init.d script also. It had a setuid line for starting as a specific user (I think). How can we use systemd start mm as a specific user?

If the issue of the OP is solved, did you install the script in /lib/systemd/system/? What permissions do you give the script?

Sorry looks like I have more than 1 question.

Thanks guys!

I find two configurations for run on systemd

first from http://zwarag.com

[Unit]
Description=mattermost
After=multi-user.target

[Service]
User=mattermost
WorkingDirectory=/var/www
ExecStart=/var/www/bin/platform
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

and second from https://www.howtoforge.com/tutorial/install-mattermost-with-postgresql-and-nginx-on-centos7/

[Unit]
Description=Mattermost
After=syslog.target network.target

[Service]
Type=simple
WorkingDirectory=/opt/mattermost/bin
User=mattermost
ExecStart=/opt/mattermost/bin/platform
PIDFile=/var/spool/mattermost/pid/master.pid

[Install]
WantedBy=multi-user.target

I’m tested only first and its working )