netdata.in 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/sbin/openrc-run
  2. # SPDX-License-Identifier: GPL-3.0-or-later
  3. NETDATA_OWNER="@netdata_user_POST@:@netdata_user_POST@"
  4. NETDATA_PIDFILE="@localstatedir_POST@/run/netdata/netdata.pid"
  5. description="Run the Netdata system monitoring agent."
  6. extra_started_commands="reload rotate"
  7. description_reload="Reload health configuration."
  8. description_rotate="Reopen log files."
  9. command_prefix="@sbindir_POST@"
  10. command="${command_prefix}/netdata"
  11. command_args="-P ${NETDATA_PIDFILE} ${NETDATA_EXTRA_ARGS}"
  12. command_args_foreground="-D"
  13. depend() {
  14. use logger
  15. need net
  16. after apache2 squid nginx mysql named opensips upsd hostapd postfix lm_sensors
  17. }
  18. start_pre() {
  19. checkpath -o ${NETDATA_OWNER} -d @localstatedir_POST@/run/netdata
  20. if [ -z "${supervisor}" ]; then
  21. pidfile="${NETDATA_PIDFILE}"
  22. fi
  23. }
  24. stop_pre() {
  25. if [ "0${NETDATA_FORCE_EXIT}" -eq 1 ]; then
  26. retry="TERM/${NETDATA_WAIT_EXIT_TIMEOUT:-60}/KILL/1"
  27. else
  28. retry="TERM/${NETDATA_WAIT_EXIT_TIMEOUT:-60}"
  29. fi
  30. }
  31. run_cmd() {
  32. cmd="${1}"
  33. msg="${2}"
  34. failmsg="${3}"
  35. signal="${4}"
  36. ebegin "${msg}"
  37. if [ "${NETDATA_USE_NETDATACLI}" = 1 ]; then
  38. "${command_prefix}/netdatacli" "${cmd}" >/dev/null
  39. eend $? "${failmsg}"
  40. elif [ "${supervisor}" = "supervise-daemon" ]; then
  41. supervise-daemon "${RC_SVCNAME}" --signal "${signal}"
  42. eend $? "${failmsg}"
  43. else
  44. start-stop-daemon --signal "${signal}" --pidfile "${pidfile}"
  45. eend $? "${failmsg}"
  46. fi
  47. }
  48. reload() {
  49. run_cmd reload-health \
  50. "Reloading Netdata health configuration" \
  51. "Failed to reload Netdata health configuration" \
  52. SIGUSR2
  53. }
  54. rotate() {
  55. run_cmd reopen-logs \
  56. "Reopening Netdata log files" \
  57. "Failed to reopen Netdata log files" \
  58. SIGHUP
  59. }