diff --git a/utils/syncthing/files/stdiscosrv.conf b/utils/syncthing/files/stdiscosrv.conf index 08a95f0396..476d618cdb 100644 --- a/utils/syncthing/files/stdiscosrv.conf +++ b/utils/syncthing/files/stdiscosrv.conf @@ -17,3 +17,16 @@ config stdiscosrv 'stdiscosrv' # option compression '0' # option debug '0' # option http '1' + + # Advanced options. Modify at your own risk. + + # More info: https://go.dev/doc/gc-guide#GOGC + # option gc '0' + + # Max number of OS threads to use + # 0 to match the number of CPUs (default) + # >0 to explicitly specify concurrency + # option maxprocs '0' + + # Soft memory limit in MB, 0 to disable + # option memlimit '0' diff --git a/utils/syncthing/files/stdiscosrv.init b/utils/syncthing/files/stdiscosrv.init index d1d3476552..a4f4f986ee 100644 --- a/utils/syncthing/files/stdiscosrv.init +++ b/utils/syncthing/files/stdiscosrv.init @@ -1,4 +1,6 @@ #!/bin/sh /etc/rc.common +# +# shellcheck disable=SC3043 # ash supports local START=90 STOP=10 @@ -35,9 +37,12 @@ start_service() { local db_dir="$conf_dir/discovery.db" local db_flush_interval='' local debug=0 + local gc=0 local http=0 local key="$conf_dir/key.pem" local listen=':8443' + local maxprocs=0 + local memlimit=0 local metrics_listen='' local nice=0 local user='syncthing' @@ -54,6 +59,11 @@ start_service() { procd_open_instance procd_set_param command "$PROG" + + [ "$gc" -le 0 ] || procd_append_param env GOGC="$gc" + [ "$maxprocs" -le 0 ] || procd_append_param env GOMAXPROCS="$maxprocs" + [ "$memlimit" -le 0 ] || procd_append_param env GOMEMLIMIT="$memlimit" + procd_append_param command --cert="$cert" [ "$compression" -eq 0 ] || \ procd_append_param command --compression diff --git a/utils/syncthing/files/strelaysrv.conf b/utils/syncthing/files/strelaysrv.conf index 3c2b40a7f2..4f4f26f912 100644 --- a/utils/syncthing/files/strelaysrv.conf +++ b/utils/syncthing/files/strelaysrv.conf @@ -27,3 +27,16 @@ config strelaysrv 'strelaysrv' # option debug '0' # option nat '0' # option pprof '0' + + # Advanced options. Modify at your own risk. + + # More info: https://go.dev/doc/gc-guide#GOGC + # option gc '0' + + # Max number of OS threads to use + # 0 to match the number of CPUs (default) + # >0 to explicitly specify concurrency + # option maxprocs '0' + + # Soft memory limit in MB, 0 to disable + # option memlimit '0' diff --git a/utils/syncthing/files/strelaysrv.init b/utils/syncthing/files/strelaysrv.init index 5bb53a9449..5e4c55e14a 100644 --- a/utils/syncthing/files/strelaysrv.init +++ b/utils/syncthing/files/strelaysrv.init @@ -1,4 +1,6 @@ #!/bin/sh /etc/rc.common +# +# shellcheck disable=SC3043 # ash supports local START=90 STOP=10 @@ -30,9 +32,12 @@ start_service() { local enabled=0 local debug=0 local ext_address='' + local gc=0 local global_rate='' local keys='/etc/strelaysrv' local listen=':22067' + local maxprocs=0 + local memlimit=0 local message_timeout='' local nat=0 local nat_lease='' @@ -64,8 +69,12 @@ start_service() { procd_open_instance procd_set_param command "$PROG" - [ "$debug" -eq 0 ] || \ - procd_append_param command -debug + + [ "$gc" -le 0 ] || procd_append_param env GOGC="$gc" + [ "$maxprocs" -le 0 ] || procd_append_param env GOMAXPROCS="$maxprocs" + [ "$memlimit" -le 0 ] || procd_append_param env GOMEMLIMIT="$memlimit" + + [ "$debug" -eq 0 ] || procd_append_param command -debug [ -z "$ext_address" ] || \ procd_append_param command -ext-address="$ext_address" [ -z "$global_rate" ] || \ diff --git a/utils/syncthing/files/syncthing.conf b/utils/syncthing/files/syncthing.conf index 2c1b6d0e2e..9c68d901cd 100644 --- a/utils/syncthing/files/syncthing.conf +++ b/utils/syncthing/files/syncthing.conf @@ -14,10 +14,6 @@ config syncthing 'syncthing' # "restart": the service has to be stopped/started for those to take effect. option nice '19' - # 0 to match the number of CPUs (default) - # >0 to explicitly specify concurrency - option maxprocs '0' - # More info: https://docs.syncthing.net/users/syncthing.html # option db_delete_retention_interval '' # option db_maintenance_interval '' @@ -31,3 +27,16 @@ config syncthing 'syncthing' option log_max_old_files '7' # Size in bytes option log_max_size '1048576' + + # Advanced options. Modify at your own risk. + + # More info: https://go.dev/doc/gc-guide#GOGC + # option gc '0' + + # Max number of OS threads to use + # 0 to match the number of CPUs (default) + # >0 to explicitly specify concurrency + # option maxprocs '0' + + # Soft memory limit in MB, 0 to disable + # option memlimit '0' diff --git a/utils/syncthing/files/syncthing.init b/utils/syncthing/files/syncthing.init index b50abf74f4..b8c93e9e5f 100644 --- a/utils/syncthing/files/syncthing.init +++ b/utils/syncthing/files/syncthing.init @@ -1,4 +1,6 @@ #!/bin/sh /etc/rc.common +# +# shellcheck disable=SC3043 # ash supports local START=90 STOP=10 @@ -41,6 +43,7 @@ start_service() { local enabled=0 local db_delete_retention_interval='' local db_maintenance_interval='' + local gc=0 local gui_address='http://0.0.0.0:8384' local gui_apikey='' local home='/etc/syncthing' @@ -49,29 +52,28 @@ start_service() { local log_max_old_files=7 local log_max_size=1048576 local maxprocs=0 + local memlimit=0 local nice=0 local user='syncthing' config_load 'syncthing' - local group=$(id -gn $user) - [ "$enabled" -gt 0 ] || return 0 + local group=$(id -gn $user) + mkdir -p "$home" # A separate step to handle an upgrade use case [ -d "$home" ] && chown -R $user:$group "$home" - # Changes to "niceness"/maxprocs are not picked up either by reload_config - # or by restart: the service has to be stopped/started for it to take effect - if [ $maxprocs -le 0 ]; then - # Default to the number of cores in this case - maxprocs=$(grep -c ^processor /proc/cpuinfo) - fi - procd_open_instance + procd_set_param command "$PROG" - procd_set_param env GOMAXPROCS="$maxprocs" + + [ "$gc" -le 0 ] || procd_append_param env GOGC="$gc" + [ "$maxprocs" -le 0 ] || procd_append_param env GOMAXPROCS="$maxprocs" + [ "$memlimit" -le 0 ] || procd_append_param env GOMEMLIMIT="$memlimit" + procd_append_param command serve [ -z "$db_delete_retention_interval" ] || \ procd_append_param command --db-delete-retention-interval="$db_delete_retention_interval" @@ -100,6 +102,7 @@ start_service() { procd_set_param respawn procd_set_param stdout 0 procd_set_param stderr 1 + procd_close_instance }