From 8c98d93311b5f1ac227adc1e29b03ba4f6648721 Mon Sep 17 00:00:00 2001 From: douglarek Date: Wed, 19 Jul 2023 17:28:26 +0800 Subject: [PATCH] daed: Support logging to a file --- net/daed/files/daed.config | 3 +++ net/daed/files/daed.init | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/net/daed/files/daed.config b/net/daed/files/daed.config index 83322e68f0..400ddd00e9 100644 --- a/net/daed/files/daed.config +++ b/net/daed/files/daed.config @@ -2,4 +2,7 @@ config daed 'config' option enabled '0' option listen_addr '0.0.0.0:2023' + option logfile_enabled '1' + option logfile_maxbackups '1' + option logfile_maxsize '1' diff --git a/net/daed/files/daed.init b/net/daed/files/daed.init index ab1dcb0f05..aa28a14e34 100644 --- a/net/daed/files/daed.init +++ b/net/daed/files/daed.init @@ -6,6 +6,7 @@ START=99 CONF="daed" PROG="/usr/bin/daed" +RUN_DIR="/var/run/daed" start_service() { config_load "$CONF" @@ -22,6 +23,19 @@ start_service() { procd_append_param command --config "/etc/daed/" procd_append_param command --listen "$listen_addr" + local logfile_enabled + config_get_bool logfile_enabled "config" "logfile_enabled" "1" + if [ "$logfile_enabled" != "0"] ; then + local logfile_maxbackups + config_get logfile_maxbackups "config" "logfile_maxbackups" "1" + local logfile_maxsize + config_get logfile_maxsize "config" "logfile_maxsize" "1" + mkdir -p "$RUN_DIR" + procd_append_param command --logfile "$RUN_DIR/daed.log" + procd_append_param command --logfile-maxbackups "$logfile_maxbackups" + procd_append_param command --logfile-maxsize "$logfile_maxsize" + fi + procd_set_param limits core="unlimited" procd_set_param limits nofile="1000000 1000000" procd_set_param respawn @@ -31,6 +45,10 @@ start_service() { procd_close_instance } +stop_service() { + rm -f "$RUN_DIR/daed.log" +} + service_triggers() { procd_add_reload_trigger "$CONF" }