Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 628328 - =www-apps/grafana-bin-4.4.1 service file does not work on systemd
Summary: =www-apps/grafana-bin-4.4.1 service file does not work on systemd
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal with 1 vote (vote)
Assignee: Ferenc Erki
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-19 19:47 UTC by Sergei Trofimovich (RETIRED)
Modified: 2018-06-12 08:46 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sergei Trofimovich (RETIRED) gentoo-dev 2017-08-19 19:47:58 UTC
The culprit is at --pidfile=/run/grafana.pid.
grafana binary is ran as user grafana and can'r write to /run.

The simplest fix is to create /run/grafana/ with appropriate permissions:

--- grafana.service     2017-04-11 10:01:26.418656724 +0100
+++ /etc/systemd/system/grafana.service 2017-08-19 20:41:24.287619856 +0100
@@ -7,14 +7,15 @@
 [Service]
 User=grafana
 Group=grafana
 Type=simple
 Restart=on-failure
+RuntimeDirectory=grafana
 WorkingDirectory=/usr/share/grafana
 ExecStart=/usr/bin/grafana-server                      \
     --config=/etc/grafana/grafana.ini                  \
-    --pidfile=/run/grafana.pid                         \
+    --pidfile=/run/grafana/grafana.pid                 \
     cfg:default.paths.logs=/var/log/grafana            \
     cfg:default.paths.data=/var/lib/grafana            \
     cfg:default.paths.plugins=/var/lib/grafana/plugins
 LimitNOFILE=10000
 TimeoutStopSec=20

I can add the same changes to /etc/init.d/grafana for symetry.

Crash logs are not very useful:

авг 19 20:38:26 sf systemd[1]: Started Grafana.
авг 19 20:38:26 sf systemd[1]: ^[[0;1;39mgrafana.service: Main process exited, code=exited, status=1/FAILURE
авг 19 20:38:26 sf systemd[1]: ^[[0;1;39mgrafana.service: Unit entered failed state.
авг 19 20:38:26 sf systemd[1]: ^[[0;1;39mgrafana.service: Failed with result 'exit-code'.
авг 19 20:38:26 sf systemd[1]: grafana.service: Service hold-off time over, scheduling restart.
авг 19 20:38:26 sf systemd[1]: Stopped Grafana.
авг 19 20:38:26 sf systemd[1]: ^[[0;1;39mgrafana.service: Start request repeated too quickly.
авг 19 20:38:26 sf systemd[1]: Failed to start Grafana.
Comment 1 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2018-06-09 20:05:43 UTC
Ping, guys.
Comment 2 Larry the Git Cow gentoo-dev 2018-06-12 08:46:31 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b69b2e648f0b668e3f5b8cec5e8a64cc33feed19

commit b69b2e648f0b668e3f5b8cec5e8a64cc33feed19
Author:     Aleksander Mistewicz <a.mistewicz@gmail.com>
AuthorDate: 2018-06-08 20:04:37 +0000
Commit:     Patrice Clement <monsieurp@gentoo.org>
CommitDate: 2018-06-12 08:46:14 +0000

    www-apps/grafana: fix pid file permission.
    
    Due to a fact that the service is running as a user named grafana, the process
    did not have permissions to create a file in /run. It could be mitigated by
    changing permissions of /run or running service as privileged user or avoiding
    systemd.  This patch moves pid file to subdirectory and adds RuntimeDirectory
    entry to the definition of the service.
    
    Closes: https://bugs.gentoo.org/628328
    
    Package-Manager: Portage-2.3.19, Repoman-2.3.6
    Closes: https://github.com/gentoo/gentoo/pull/8765

 www-apps/grafana-bin/files/grafana.service | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)