@cryptotaxi247 / netdata-1 / commits / 10183008d

make sure the run directory expected to save the pid, exists #204

Costa Tsaousis (ktsaou) committed Apr 10, 2016 at 13:14 UTC 10183008d61020722e89f76aa268cc1a0e81a400
1 file changed +13 -3
netdata-installer.sh
+13 -3
@@ -111,6 +111,7 @@ It will be installed at these locations:
111 - plugins at ${NETDATA_PREFIX}/usr/libexec/netdata
112 - cache files at ${NETDATA_PREFIX}/var/cache/netdata
113 - log files at ${NETDATA_PREFIX}/var/log/netdata
114 + - pid file at ${NETDATA_PREFIX}/var/run
115
116 This installer allows you to change the installation path.
117 Press Control-C and run the same command with --help for help.
@@ -317,11 +318,18 @@ NETDATA_CACHE_DIR="$( config_option "cache directory" "${NETDATA_PREFIX}/var/cac
318 NETDATA_WEB_DIR="$( config_option "web files directory" "${NETDATA_PREFIX}/usr/share/netdata/web" )"
319 NETDATA_LOG_DIR="$( config_option "log directory" "${NETDATA_PREFIX}/var/log/netdata" )"
320 NETDATA_CONF_DIR="$( config_option "config directory" "${NETDATA_PREFIX}/etc/netdata" )"
321 +NETDATA_RUN_DIR="${NETDATA_PREFIX}/var/run"
322
323
324 # -----------------------------------------------------------------------------
325 # prepare the directories
326
327 +# this is needed if NETDATA_PREFIX is not empty
328 +if [ ! -d "${NETDATA_RUN_DIR}" ]
329 + then
330 + mkdir -p "${NETDATA_RUN_DIR}" || exit 1
331 +fi
332 +
333 echo >&2 "Fixing directory permissions for user ${NETDATA_USER}..."
334 for x in "${NETDATA_WEB_DIR}" "${NETDATA_CONF_DIR}" "${NETDATA_CACHE_DIR}" "${NETDATA_LOG_DIR}"
335 do
@@ -370,7 +378,7 @@ ret=0
378 count=0
379 while [ $ret -eq 0 ]
380 do
373 - if [ $count -gt 15 ]
381 + if [ $count -gt 30 ]
382 then
383 echo >&2 "Cannot stop the running netdata."
384 exit 1
@@ -378,8 +386,9 @@ do
386
387 count=$((count + 1))
388
381 - pid=$(cat /var/run/netdata.pid 2>/dev/null)
389 + pid=$(cat "${NETDATA_RUN_DIR}/netdata.pid" 2>/dev/null)
390 # backwards compatibility
391 + [ -z "${pid}" ] && pid=$(cat /var/run/netdata.pid 2>/dev/null)
392 [ -z "${pid}" ] && pid=$(cat /var/run/netdata/netdata.pid 2>/dev/null)
393
394 isnetdata $pid || pid=
@@ -395,13 +404,14 @@ do
404 test $ret -eq 0 && printf >&2 "." && sleep 2
405 done
406 echo >&2
407 +echo >&2
408
409
410 # -----------------------------------------------------------------------------
411 # run netdata
412
413 echo >&2 "Starting netdata..."
404 -run ${NETDATA_PREFIX}/usr/sbin/netdata -pidfile /var/run/netdata.pid "${@}"
414 +run ${NETDATA_PREFIX}/usr/sbin/netdata -pidfile ${NETDATA_RUN_DIR}/netdata.pid "${@}"
415
416 if [ $? -ne 0 ]
417 then