mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
packaging: fixed issue with pid file on systemd systems, fixes #9133
This commit is contained in:
@@ -6,6 +6,7 @@ set -e
|
||||
|
||||
IS_UPGRADE=false
|
||||
|
||||
|
||||
case "$1" in
|
||||
configure)
|
||||
[ -z "$GRAFANA_USER" ] && GRAFANA_USER="grafana"
|
||||
@@ -41,6 +42,12 @@ case "$1" in
|
||||
IS_UPGRADE=true
|
||||
fi
|
||||
|
||||
# make sure there is a /var/run/grafana dir on systemd systems
|
||||
if [ -x /bin/systemctl ] ; then
|
||||
mkdir -p $PID_FILE_DIR
|
||||
chown -R $GRAFANA_USER:$GRAFANA_GROUP $PID_FILE_DIR
|
||||
fi
|
||||
|
||||
if [ "x$IS_UPGRADE" != "xtrue" ]; then
|
||||
if command -v systemctl >/dev/null; then
|
||||
echo "### NOT starting on installation, please execute the following statements to configure grafana to start automatically using systemd"
|
||||
|
||||
@@ -17,3 +17,6 @@ CONF_FILE=/etc/grafana/grafana.ini
|
||||
RESTART_ON_UPGRADE=true
|
||||
|
||||
PLUGINS_DIR=/var/lib/grafana/plugins
|
||||
|
||||
# Only used on systemd systems
|
||||
PID_FILE_DIR=/var/run/grafana
|
||||
|
||||
@@ -12,11 +12,11 @@ Group=grafana
|
||||
Type=simple
|
||||
Restart=on-failure
|
||||
WorkingDirectory=/usr/share/grafana
|
||||
ExecStart=/usr/sbin/grafana-server \
|
||||
--config=${CONF_FILE} \
|
||||
--pidfile=${PID_FILE} \
|
||||
cfg:default.paths.logs=${LOG_DIR} \
|
||||
cfg:default.paths.data=${DATA_DIR} \
|
||||
ExecStart=/usr/sbin/grafana-server \
|
||||
--config=${CONF_FILE} \
|
||||
--pidfile=${PID_FILE_DIR}/grafana-server.pid \
|
||||
cfg:default.paths.logs=${LOG_DIR} \
|
||||
cfg:default.paths.data=${DATA_DIR} \
|
||||
cfg:default.paths.plugins=${PLUGINS_DIR}
|
||||
LimitNOFILE=10000
|
||||
TimeoutStopSec=20
|
||||
|
||||
@@ -25,6 +25,7 @@ stopGrafana() {
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Initial installation: $1 == 1
|
||||
# Upgrade: $1 == 2, and configured to restart on upgrade
|
||||
if [ $1 -eq 1 ] ; then
|
||||
@@ -55,6 +56,12 @@ if [ $1 -eq 1 ] ; then
|
||||
find /etc/grafana -type f -exec chmod 640 {} ';'
|
||||
find /etc/grafana -type d -exec chmod 755 {} ';'
|
||||
|
||||
# make sure there is a /var/run/grafana dir on systemd systems
|
||||
if [ -x /bin/systemctl ] ; then
|
||||
mkdir -p $PID_FILE_DIR
|
||||
chown -R $GRAFANA_USER:$GRAFANA_GROUP $PID_FILE_DIR
|
||||
fi
|
||||
|
||||
if [ -x /bin/systemctl ] ; then
|
||||
echo "### NOT starting on installation, please execute the following statements to configure grafana to start automatically using systemd"
|
||||
echo " sudo /bin/systemctl daemon-reload"
|
||||
@@ -68,6 +75,12 @@ if [ $1 -eq 1 ] ; then
|
||||
echo " sudo service grafana-server start"
|
||||
fi
|
||||
elif [ $1 -ge 2 ] ; then
|
||||
# make sure there is a /var/run/grafana dir on systemd systems
|
||||
if [ -x /bin/systemctl ] ; then
|
||||
mkdir -p $PID_FILE_DIR
|
||||
chown -R $GRAFANA_USER:$GRAFANA_GROUP $PID_FILE_DIR
|
||||
fi
|
||||
|
||||
if [ "$RESTART_ON_UPGRADE" == "true" ]; then
|
||||
stopGrafana
|
||||
startGrafana
|
||||
|
||||
@@ -17,3 +17,6 @@ CONF_FILE=/etc/grafana/grafana.ini
|
||||
RESTART_ON_UPGRADE=true
|
||||
|
||||
PLUGINS_DIR=/var/lib/grafana/plugins
|
||||
|
||||
# Only used on systemd systems
|
||||
PID_FILE_DIR=/var/run/grafana
|
||||
|
||||
@@ -12,11 +12,11 @@ Group=grafana
|
||||
Type=simple
|
||||
Restart=on-failure
|
||||
WorkingDirectory=/usr/share/grafana
|
||||
ExecStart=/usr/sbin/grafana-server \
|
||||
--config=${CONF_FILE} \
|
||||
--pidfile=${PID_FILE} \
|
||||
cfg:default.paths.logs=${LOG_DIR} \
|
||||
cfg:default.paths.data=${DATA_DIR} \
|
||||
ExecStart=/usr/sbin/grafana-server \
|
||||
--config=${CONF_FILE} \
|
||||
--pidfile=${PID_FILE_DIR}/grafana-server.pid \
|
||||
cfg:default.paths.logs=${LOG_DIR} \
|
||||
cfg:default.paths.data=${DATA_DIR} \
|
||||
cfg:default.paths.plugins=${PLUGINS_DIR}
|
||||
LimitNOFILE=10000
|
||||
TimeoutStopSec=20
|
||||
|
||||
Reference in New Issue
Block a user