Starting mattermost with /etc/init.d/mattermost start failed

For feature requests, please see: Contributing Feature Proposals - Mattermost.

For troubleshooting questions, please post in the following format:

Summary

Starting mattermost with ./platform works
But starting mattermost with systemctl start mattermost failed

Steps to reproduce

Debian Jessie:
Linux version 3.16.0-4-amd64 (debian-kernel@lists.debian.org) (gcc version 4.8.4 (Debian 4.8.4-1) ) #1 SMP Debian 3.16.7-ckt25-2+deb8u3 (2016-07-02)

Mattermost:
Version 3.2.0

Expected behavior

executing
/etc/init.d/mattermost start
should start mattermost daemon

Observed behavior

executing
/etc/init.d/mattermost start
shows
[ ok ] Starting mattermost (via systemctl): mattermost.service.

But mattermost is not reachable.
Nginx shows 502 Bad Gateway

/etc/init.d/mattermost status
shows

● mattermost.service - Mattermost is an open source, self-hosted Slack-alternative
Loaded: loaded (/etc/systemd/system/mattermost.service; enabled)
Active: activating (auto-restart) (Result: exit-code) since Mi 2016-07-20 08:01:49 CEST; 23s ago
Process: 13589 ExecStart=/opt/mattermost/bin/platform (code=exited, status=2)
Main PID: 13589 (code=exited, status=2)

in /var/syslog

Jul 20 08:07:52 mattermost platform[13711]: FileLogWriter(“/opt/mattermost/logs/mattermost.log”): open /opt/mattermost/logs/mattermost.log: permission denied
Jul 20 08:07:52 mattermost platform[13711]: panic: runtime error: invalid memory address or nil pointer dereference [recovered]
Jul 20 08:07:52 mattermost platform[13711]: panic: interface conversion: interface is runtime.errorString, not string
Jul 20 08:07:52 mattermost platform[13711]: [signal 0xb code=0x1 addr=0x0 pc=0x775569]
Jul 20 08:07:52 mattermost platform[13711]: goroutine 1 [running]:
Jul 20 08:07:52 mattermost platform[13711]: panic(0xcd1aa0, 0xc820043a80)
Jul 20 08:07:52 mattermost platform[13711]: /usr/local/go/src/runtime/panic.go:481 +0x3e6
Jul 20 08:07:52 mattermost platform[13711]: main.doLoadConfig.func1(0xc820145d48)
Jul 20 08:07:52 mattermost platform[13711]: /var/lib/jenkins/jobs/mattermost-platform-release/workspace/src/github.com/mattermost/platform/mattermost.go:73 +0x6f
Jul 20 08:07:52 mattermost platform[13711]: panic(0xccbec0, 0xc82000a0a0)
Jul 20 08:07:52 mattermost platform[13711]: /usr/local/go/src/runtime/panic.go:443 +0x4e9
Jul 20 08:07:52 mattermost platform[13711]: github.com/mattermost/platform/utils.configureLog(0xc820070c70)
Jul 20 08:07:52 mattermost platform[13711]: /var/lib/jenkins/jobs/mattermost-platform-release/workspace/src/github.com/mattermost/platform/utils/config.go:108 +0x539
Jul 20 08:07:52 mattermost platform[13711]: github.com/mattermost/platform/utils.LoadConfig(0xc820129a70, 0x22)
Jul 20 08:07:52 mattermost platform[13711]: /var/lib/jenkins/jobs/mattermost-platform-release/workspace/src/github.com/mattermost/platform/utils/config.go:180 +0x109c
Jul 20 08:07:52 mattermost platform[13711]: main.doLoadConfig(0xdce990, 0xb, 0x0, 0x0)
Jul 20 08:07:52 mattermost platform[13711]: /var/lib/jenkins/jobs/mattermost-platform-release/workspace/src/github.com/mattermost/platform/mattermost.go:76 +0x6a
Jul 20 08:07:52 mattermost platform[13711]: main.main()
Jul 20 08:07:52 mattermost platform[13711]: /var/lib/jenkins/jobs/mattermost-platform-release/workspace/src/github.com/mattermost/platform/mattermost.go:84 +0x43
Jul 20 08:07:52 mattermost systemd[1]: mattermost.service: main process exited, code=exited, status=2/INVALIDARGUMENT
Jul 20 08:07:52 mattermost systemd[1]: Unit mattermost.service entered failed state.

It looks like Mattermost doesn’t have write permissions where it is trying to write it’s log file. Make sure it has permissions there and to the data directory. Both are specified in the config.json.